From 2933dfdc51c07e160c95d26ce8b4c771f7c78717 Mon Sep 17 00:00:00 2001 From: Stanislav Egorov Date: Wed, 25 Mar 2020 13:16:36 -0700 Subject: [PATCH] Moved last role to airshipctl All roles should be developed in airshipctl roles dir Change-Id: Ide949c95889746595d41c4db913619f7140daf35 --- roles/docker-install/defaults/main.yaml | 5 ++ roles/docker-install/tasks/main.yaml | 66 +++++++++++++++++++ .../templates/http-proxy-conf.j2 | 4 ++ roles/docker-install/tests/main.yml | 13 ++++ tools/gate/00_setup.sh | 5 +- zuul.d/jobs.yaml | 4 -- 6 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 roles/docker-install/defaults/main.yaml create mode 100644 roles/docker-install/tasks/main.yaml create mode 100644 roles/docker-install/templates/http-proxy-conf.j2 create mode 100644 roles/docker-install/tests/main.yml diff --git a/roles/docker-install/defaults/main.yaml b/roles/docker-install/defaults/main.yaml new file mode 100644 index 000000000..014c9fab8 --- /dev/null +++ b/roles/docker-install/defaults/main.yaml @@ -0,0 +1,5 @@ +proxy: + enabled: false + http: + https: + noproxy: diff --git a/roles/docker-install/tasks/main.yaml b/roles/docker-install/tasks/main.yaml new file mode 100644 index 000000000..925cc0613 --- /dev/null +++ b/roles/docker-install/tasks/main.yaml @@ -0,0 +1,66 @@ +--- +- name: Ensuring docker and support packages are present + become: true + when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' + yum: + name: + - docker.io + - runc + update_cache: yes + state: present + +- name: Ensuring docker and support packages are present + become: true + when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' + apt: + name: + - docker.io + - runc + update_cache: yes + state: present + +- name: Ensure docker group exists + group: + name: docker + state: present + +- name: Add user "{{ ansible_user }}" to docker group + become: true + user: + name: "{{ ansible_user }}" + groups: + - docker + append: yes + +- name: Reset ssh connection to add docker group to user + meta: reset_connection + ignore_errors: true + +- block: + - name: Create docker directory + file: + path: /etc/systemd/system/docker.service.d/ + state: directory + mode: '0755' + + - name: Configure proxy for docker if enabled + template: + src: http-proxy-conf.j2 + dest: /etc/systemd/system/docker.service.d/http-proxy.conf + when: proxy.enabled|bool == true + become: true + +- name: Start docker + become: true + systemd: + name: docker + state: restarted + daemon_reload: yes + enabled: true + +- name: Change group ownership on docker sock + become: true + file: + path: /var/run/docker.sock + group: docker + diff --git a/roles/docker-install/templates/http-proxy-conf.j2 b/roles/docker-install/templates/http-proxy-conf.j2 new file mode 100644 index 000000000..90d8e1d53 --- /dev/null +++ b/roles/docker-install/templates/http-proxy-conf.j2 @@ -0,0 +1,4 @@ +[Service] +Environment="HTTP_PROXY={{ proxy.http }}" +Environment="HTTPS_PROXY={{ proxy.https }}" +Environment="NO_PROXY={{ proxy.noproxy }}" diff --git a/roles/docker-install/tests/main.yml b/roles/docker-install/tests/main.yml new file mode 100644 index 000000000..73c8163d1 --- /dev/null +++ b/roles/docker-install/tests/main.yml @@ -0,0 +1,13 @@ +- name: install docker + include_role: + name: docker-install + +- name: check if docker is installed + shell: "docker version" + register: docker_version + +- name: verify docker is installed + assert: + that: + - docker_version.rc == 0 + diff --git a/tools/gate/00_setup.sh b/tools/gate/00_setup.sh index cad9175ad..e5a1af9a0 100755 --- a/tools/gate/00_setup.sh +++ b/tools/gate/00_setup.sh @@ -27,7 +27,6 @@ export TMP_DIR=${TMP_DIR:-"$(dirname $(mktemp -u))"} ANSIBLE_CFG=${ANSIBLE_CFG:-"${HOME}/.ansible.cfg"} ANSIBLE_HOSTS=${ANSIBLE_HOSTS:-"${TMP_DIR}/ansible_hosts"} PLAYBOOK_CONFIG=${PLAYBOOK_CONFIG:-"${TMP_DIR}/config.yaml"} -OSH_INFRA_DIR=${OSH_INFRA_DIR:-"${TMP_DIR}/openstack-helm-infra"} mkdir -p "$TMP_DIR" envsubst <"${AIRSHIPCTL_WS}/tools/gate/config_template.yaml" > "$PLAYBOOK_CONFIG" @@ -39,6 +38,4 @@ sudo apt-get -y update sudo apt-get -y --no-install-recommends install docker.io ansible make echo "primary ansible_host=localhost ansible_connection=local" > "$ANSIBLE_HOSTS" -printf "[defaults]\nroles_path = %s/roles:%s/roles\n" "$AIRSHIPCTL_WS" "$OSH_INFRA_DIR" > "$ANSIBLE_CFG" -rm -rf "$OSH_INFRA_DIR" -git clone https://review.opendev.org/openstack/openstack-helm-infra.git "$OSH_INFRA_DIR" +printf "[defaults]\nroles_path = %s/roles\n" "$AIRSHIPCTL_WS" > "$ANSIBLE_CFG" diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 2cb9ad794..d923fa37f 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -25,8 +25,6 @@ - job: name: airship-airshipctl-lint-unit - roles: - - zuul: airship/zuul-airship-roles pre-run: playbooks/airship-airshipctl-deploy-docker.yaml run: playbooks/airship-airshipctl-lint-unit.yaml nodeset: airship-airshipctl-single-node @@ -42,8 +40,6 @@ - job: name: airship-airshipctl-build-image - roles: - - zuul: airship/zuul-airship-roles nodeset: airship-airshipctl-single-node run: playbooks/airship-airshipctl-build-images.yaml irrelevant-files: