From b2d75409728f0b74596a2c3a51f6565a52caa651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Ollivier?= Date: Thu, 9 Feb 2023 13:17:44 +0100 Subject: [PATCH] Support Alpine 16 and newer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It would allow running it in Docker Playground. Signed-off-by: Cédric Ollivier --- README.md | 18 ++++++ handlers/main.yml | 3 +- meta/main.yml | 3 + tasks/alpine.yml | 152 ++++++++++++++++++++++++++++++++++++++++++++++ tasks/docker.yml | 11 +++- tasks/main.yml | 4 ++ 6 files changed, 187 insertions(+), 4 deletions(-) create mode 100644 tasks/alpine.yml diff --git a/README.md b/README.md index 72e8030..a086929 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,24 @@ ansible-galaxy collection install ansible.posix community.general community.graf community.kubernetes community.docker community.postgresql ``` +Install dependencies (Alpine 3.16): +```bash +sudo apk update && sudo apk add git +[ -z "$VIRTUAL_ENV" ] && sudo apk add ansible +ansible-galaxy install collivier.xtesting +ansible-galaxy collection install ansible.posix community.general community.grafana \ + community.kubernetes community.docker community.postgresql +``` + +**Install dependencies (Alpine 3.17):** +```bash +sudo apk update && sudo apk add git +[ -z "$VIRTUAL_ENV" ] && sudo apk add ansible +ansible-galaxy install collivier.xtesting +ansible-galaxy collection install ansible.posix community.general community.grafana \ + community.kubernetes community.docker community.postgresql +``` + ## If proxy All Xtesting CI playbooks could be executed behind a proxy and the proxy diff --git a/handlers/main.yml b/handlers/main.yml index 8841f10..8c7c12b 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,9 +1,8 @@ --- - name: Restarting Docker become: true - ansible.builtin.systemd: + ansible.builtin.service: name: docker - daemon_reload: true state: restarted notify: - Pausing 10 seconds diff --git a/meta/main.yml b/meta/main.yml index 09c73fc..001f3d3 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -25,5 +25,8 @@ galaxy_info: - '7' - '8' - '9' + - name: "Alpine" + versions: + - all galaxy_tags: [] dependencies: [] diff --git a/tasks/alpine.yml b/tasks/alpine.yml new file mode 100644 index 0000000..640842a --- /dev/null +++ b/tasks/alpine.yml @@ -0,0 +1,152 @@ +--- +- name: Checking Alpine version + ansible.builtin.fail: + msg: Only Alpine 16 and newer are supported + when: + - "ansible_distribution_version is version('3.16.0', 'lt', version_type='semver')" +- name: Gathering the package facts + ansible.builtin.package_facts: + manager: auto +- name: Installing py3-pip and py3-setuptools + become: true + ansible.builtin.apk: + name: + - py3-pip + - py3-setuptools + update_cache: true + register: apk_res + retries: 5 + until: apk_res is success + when: + - not lookup('env', 'VIRTUAL_ENV') +- name: Installing docker + become: true + ansible.builtin.apk: + name: + - docker + update_cache: true + register: apk_res + retries: 5 + until: apk_res is success +- name: Installing py3-certifi, py3-charset-normalizer, py3-fasteners, + py3-pbr, py3-requests, py3-urllib3 and py3-multi-key-dict + become: true + ansible.builtin.apk: + name: + - py3-certifi + - py3-charset-normalizer + - py3-fasteners + - py3-pbr + - py3-requests + - py3-urllib3 + - py3-multi-key-dict + update_cache: true + register: apk_res + retries: 5 + until: apk_res is success + when: + - jenkins_deploy or jenkins_configure or jenkins_create_jobs +- name: Installing stevedore, python-jenkins and jenkins-job-builder via pip + become: "{{ not lookup('env', 'VIRTUAL_ENV') }}" + ansible.builtin.pip: + name: + - stevedore<=1.31.0 + - python-jenkins<=1.7.0 + - jenkins-job-builder<=4.1.0 + extra_args: --no-deps + when: + - jenkins_deploy or jenkins_configure +- name: Installing py3-jmespath + become: true + ansible.builtin.apk: + name: py3-jmespath + update_cache: true + register: apk_res + retries: 5 + until: apk_res is success + when: + - gitlab_deploy or gitlab_configure +- name: Installing git + become: true + ansible.builtin.apk: + name: git + update_cache: true + register: apt_res + retries: 5 + until: apk_res is success + when: + - gitlab_create_jobs +- name: Installing py3-psycopg2 + become: true + ansible.builtin.apk: + name: py3-psycopg2 + update_cache: true + register: apk_res + retries: 5 + until: apk_res is success + when: + - postgres_deploy or cachet_configure +- name: Installing py3-influxdb + become: true + ansible.builtin.apk: + name: py3-influxdb + update_cache: true + register: apk_res + retries: 5 + until: apk_res is success + when: + - influxdb_deploy +- name: Installing py3-kubernetes + become: true + ansible.builtin.apk: + name: py3-kubernetes + update_cache: true + register: apk_res + retries: 5 + until: apk_res is success + when: + - use_kubernetes +- name: Installing py3-boto3, py3-gitpython, py3-grpcio, py3-protobuf, + py3-s3transfer, py3-smmap2, py3-oauthlib, py3-ruamel.yaml and + py3-ruamel.yaml.clib + become: true + ansible.builtin.apk: + name: + - py3-boto3 + - py3-gitpython + - py3-grpcio + - py3-protobuf + - py3-s3transfer + - py3-smmap2 + - py3-oauthlib + - py3-ruamel.yaml + - py3-ruamel.yaml.clib + update_cache: true + register: apk_res + retries: 5 + until: apk_res is success + when: + - use_kubernetes +- name: Installing python-string-utils, supermutes, pyhelm and openshift + via pip + become: "{{ not lookup('env', 'VIRTUAL_ENV') }}" + ansible.builtin.pip: + name: + - python-string-utils<=1.0.0 + - supermutes<=0.2.5 + - pyhelm<=2.14.5 + - openshift<=0.12.0 + extra_args: --no-deps + when: + - use_kubernetes +- name: Installing tar + become: true + ansible.builtin.apk: + name: + - tar + update_cache: true + register: apk_res + retries: 5 + until: apk_res is success + when: + - use_kubernetes diff --git a/tasks/docker.yml b/tasks/docker.yml index bf03fc4..418092b 100644 --- a/tasks/docker.yml +++ b/tasks/docker.yml @@ -1,9 +1,8 @@ --- - name: Ensuring docker service is running become: true - ansible.builtin.systemd: + ansible.builtin.service: name: docker - daemon_reload: true state: started - name: Adding ansible_user to docker group become: true @@ -22,6 +21,7 @@ mode: '0755' when: - "'http_proxy' in ansible_env or 'https_proxy' in ansible_env" + - ansible_service_mgr == "systemd" - name: Creating /etc/systemd/system/docker.service.d/http-proxy.conf become: true ansible.builtin.template: @@ -33,6 +33,13 @@ - Restarting Docker when: - "'http_proxy' in ansible_env or 'https_proxy' in ansible_env" + - ansible_service_mgr == "systemd" +- name: Forcing systemd to reread configs + ansible.builtin.systemd: + daemon_reload: true + when: + - "'http_proxy' in ansible_env or 'https_proxy' in ansible_env" + - ansible_service_mgr == "systemd" - name: Creating /etc/docker/daemon.json become: true ansible.builtin.template: diff --git a/tasks/main.yml b/tasks/main.yml index 2a82e04..85d4657 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,6 +16,10 @@ ansible.builtin.include_tasks: redhat.yml when: - ansible_os_family == 'RedHat' +- name: Include alpine.yml in play + ansible.builtin.include_tasks: alpine.yml + when: + - ansible_os_family == 'Alpine' - name: Include docker.yml in play ansible.builtin.include_tasks: docker.yml when: