From: Kienan Stewart Date: Mon, 22 Jan 2024 15:43:31 +0000 (-0500) Subject: ansible: Add docker role for developer nodes X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=14cd8ac5d22422ec859e529ab5b58882123d21c8;p=lttng-ci.git ansible: Add docker role for developer nodes Change-Id: If8df43b443c547f9229c8502146c4c2b9456afc2 Signed-off-by: Kienan Stewart --- diff --git a/automation/ansible/roles/docker/defaults/main.yml b/automation/ansible/roles/docker/defaults/main.yml new file mode 100644 index 0000000..a5f2b6d --- /dev/null +++ b/automation/ansible/roles/docker/defaults/main.yml @@ -0,0 +1,13 @@ +--- + +docker_upstream: true +docker_upstream_packages: + - 'docker-ce' + - 'docker-ce-cli' + - 'containerd.io' + - 'docker-buildx-plugin' + - 'docker-compose-plugin' + +docker_Debian_packages: + - 'docker.io' + - 'docker-compose' diff --git a/automation/ansible/roles/docker/files/daemon.json b/automation/ansible/roles/docker/files/daemon.json new file mode 100644 index 0000000..ac52aef --- /dev/null +++ b/automation/ansible/roles/docker/files/daemon.json @@ -0,0 +1,7 @@ +{ + "bip": "10.11.0.1/16", + "default-address-pools": + [ + {"base":"10.10.0.0/16","size":24} + ] +} diff --git a/automation/ansible/roles/docker/handlers/main.yml b/automation/ansible/roles/docker/handlers/main.yml new file mode 100644 index 0000000..2ec6cb1 --- /dev/null +++ b/automation/ansible/roles/docker/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: 'Restart docker' + ansible.builtin.service: + name: 'docker' + state: 'restarted' diff --git a/automation/ansible/roles/docker/tasks/main.yml b/automation/ansible/roles/docker/tasks/main.yml new file mode 100644 index 0000000..775c70c --- /dev/null +++ b/automation/ansible/roles/docker/tasks/main.yml @@ -0,0 +1,42 @@ +--- + +- when: ansible_distribution_release in ['trixie', 'sid'] + ansible.builtin.set_fact: + docker_upstream: false +- ansible.builtin.set_fact: + docker_packages: "{{docker_upstream|ternary(docker_upstream_packages, lookup('vars', 'docker_' + ansible_distribution + '_packages', default=[]))}}" +- when: docker_upstream + block: + - name: Add upstream docker apt key + ansible.builtin.apt_key: + url: 'https://download.docker.com/linux/debian/gpg' + - name: Add upstream docker sources + when: ansible_distribution == 'Debian' + ansible.builtin.apt_repository: + filename: 'docker' + repo: "deb https://download.docker.com/linux/debian {{ansible_distribution_release}} stable" +- name: Deploy docker network configuration + block: + - name: Create docker configuration directory + ansible.builtin.file: + path: '/etc/docker' + state: 'directory' + owner: 'root' + group: 'root' + mode: '0755' + - name: Copy docker configuration + ansible.builtin.copy: + src: 'daemon.json' + dest: '/etc/docker/daemon.json' + owner: 'root' + group: 'root' + mode: '0644' + notify: + - 'Restart docker' +- name: Install docker + ansible.builtin.package: + name: "{{docker_packages}}" +- name: Ensure docker is running + ansible.builtin.service: + name: 'docker' + state: 'started' diff --git a/automation/ansible/site.yml b/automation/ansible/site.yml index a9fef39..b113e9a 100644 --- a/automation/ansible/site.yml +++ b/automation/ansible/site.yml @@ -30,3 +30,4 @@ - hosts: developer roles: - developer + - docker