Browse Source

[#106] Add docker install role

This PS adds role which installs docker

Change-Id: Icf8e33f36dfc72327255b9949f0efd9f5f5f8b55
Signed-off-by: Sreejith Punnapuzha <sreejith.punnapuzha@outlook.com>
changes/09/714109/8
Sreejith Punnapuzha 2 years ago
parent
commit
6efee27b0c
  1. 5
      roles/docker-install/defaults/main.yaml
  2. 66
      roles/docker-install/tasks/main.yaml
  3. 4
      roles/docker-install/templates/http-proxy-conf.j2
  4. 13
      roles/docker-install/tests/main.yml
  5. 1
      tests/ansible/role-test-runner.yml
  6. 7
      zuul.d/jobs.yaml
  7. 2
      zuul.d/project.yaml

5
roles/docker-install/defaults/main.yaml

@ -0,0 +1,5 @@
proxy:
enabled: false
http:
https:
noproxy:

66
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

4
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 }}"

13
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

1
tests/ansible/role-test-runner.yml

@ -11,6 +11,7 @@
- redfish-emulator
- airship-libvirt-gate
- http-fileserver
- docker-install
- name: run tests against defined roles
include_tasks: "../../roles/{{ role_name }}/tests/main.yml"
with_items: "{{ test_subject_roles | default(test_subject_roles_default) }}"

7
zuul.d/jobs.yaml

@ -43,3 +43,10 @@
- airship-libvirt-gate
nodeset: ubuntu-single-airship
- job:
name: zuul-airship-roles-test-docker
run: tests/ansible/role-test-runner.yml
vars:
test_subject_roles:
- docker-install
nodeset: ubuntu-single-airship

2
zuul.d/project.yaml

@ -3,11 +3,13 @@
jobs:
- ansible-lint-airship
- zuul-airship-roles-test-libvirt
- zuul-airship-roles-test-docker
- zuul-airship-roles-test-airship-gate
- zuul-airship-roles-fileserver
gate:
jobs:
- ansible-lint-airship
- zuul-airship-roles-test-libvirt
- zuul-airship-roles-test-docker
- zuul-airship-roles-test-airship-gate
- zuul-airship-roles-fileserver

Loading…
Cancel
Save