[#106] Add docker install role

This PS adds role which installs docker

Change-Id: Icf8e33f36dfc72327255b9949f0efd9f5f5f8b55
Signed-off-by: Sreejith Punnapuzha <sreejith.punnapuzha@outlook.com>
This commit is contained in:
Sreejith Punnapuzha 2020-03-20 08:21:06 -05:00
parent 3b7fdd8f6b
commit 615ac51020
7 changed files with 93 additions and 0 deletions

View File

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

View File

@ -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

View File

@ -0,0 +1,4 @@
[Service]
Environment="HTTP_PROXY={{ proxy.http }}"
Environment="HTTPS_PROXY={{ proxy.https }}"
Environment="NO_PROXY={{ proxy.noproxy }}"

View File

@ -0,0 +1,8 @@
- name: install docker
include_role:
name: docker-install
- name: check if docker is installed
assert:
that:
- docker ps

View File

@ -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) }}"

View File

@ -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

View File

@ -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