diff --git a/project/main.yml b/project/main.yml index fa1afe3..2250618 100644 --- a/project/main.yml +++ b/project/main.yml @@ -7,6 +7,7 @@ - hosts: all roles: - common + - docker - hosts: docker2.t-juice.club roles: diff --git a/project/roles/docker/files/docker-archive-keyring.gpg b/project/roles/docker/files/docker-archive-keyring.gpg new file mode 100644 index 0000000..e5dc8cf Binary files /dev/null and b/project/roles/docker/files/docker-archive-keyring.gpg differ diff --git a/project/roles/docker/files/docker-ce.repo b/project/roles/docker/files/docker-ce.repo new file mode 100644 index 0000000..ab96bbb --- /dev/null +++ b/project/roles/docker/files/docker-ce.repo @@ -0,0 +1,82 @@ +[docker-ce-stable] +name=Docker CE Stable - $basearch +baseurl=https://download.docker.com/linux/centos/7/$basearch/stable +enabled=1 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-stable-debuginfo] +name=Docker CE Stable - Debuginfo $basearch +baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-stable-source] +name=Docker CE Stable - Sources +baseurl=https://download.docker.com/linux/centos/7/source/stable +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-edge] +name=Docker CE Edge - $basearch +baseurl=https://download.docker.com/linux/centos/7/$basearch/edge +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-edge-debuginfo] +name=Docker CE Edge - Debuginfo $basearch +baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/edge +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-edge-source] [1/6021]name=Docker CE Edge - Sources +baseurl=https://download.docker.com/linux/centos/7/source/edge +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-test] +name=Docker CE Test - $basearch +baseurl=https://download.docker.com/linux/centos/7/$basearch/test +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-test-debuginfo] +name=Docker CE Test - Debuginfo $basearch +baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/test +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-test-source] +name=Docker CE Test - Sources +baseurl=https://download.docker.com/linux/centos/7/source/test +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-nightly] +name=Docker CE Nightly - $basearch +baseurl=https://download.docker.com/linux/centos/7/$basearch/nightly +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-nightly-debuginfo] +name=Docker CE Nightly - Debuginfo $basearch +baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/nightly +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg + +[docker-ce-nightly-source] +name=Docker CE Nightly - Sources +baseurl=https://download.docker.com/linux/centos/7/source/nightly +enabled=0 +gpgcheck=1 +gpgkey=https://download.docker.com/linux/centos/gpg diff --git a/project/roles/docker/files/docker.list b/project/roles/docker/files/docker.list new file mode 100644 index 0000000..12935bc --- /dev/null +++ b/project/roles/docker/files/docker.list @@ -0,0 +1 @@ +deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian bullseye stable \ No newline at end of file diff --git a/project/roles/docker/tasks/main.yml b/project/roles/docker/tasks/main.yml new file mode 100644 index 0000000..5ba9655 --- /dev/null +++ b/project/roles/docker/tasks/main.yml @@ -0,0 +1,14 @@ +--- +- name: Install debian packages + import_tasks: packages_debian.yml + when: ansible_facts['os_family'] == 'Debian' + +- name: Install rhel packages + import_tasks: packages_redhat.yml + when: ansible_facts['os_family'] == 'RedHat' + +- name: Ensure service is started and enabled + ansible.builtin.systemd: + name: docker + state: started + enabled: yes \ No newline at end of file diff --git a/project/roles/docker/tasks/packages_debian.yml b/project/roles/docker/tasks/packages_debian.yml new file mode 100644 index 0000000..e7a9e8a --- /dev/null +++ b/project/roles/docker/tasks/packages_debian.yml @@ -0,0 +1,29 @@ +--- +- name: Remove unwanted packages + ansible.builtin.apt: + name: + - docker + - docker-engine + - docker.io + - containerd + - runc + state: absent + +- name: Add docker repo signing key + ansible.builtin.copy: + src: docker-archive-keyring.gpg + dest: /usr/share/keyrings/docker-archive-keyring.gpg + +- name: Add docker repo + ansible.builtin.copy: + src: docker.list + dest: /etc/apt/sources.list.d/docker.list + +- name: Install docker packages + ansible.builtin.apt: + name: + - docker-ce-cli + - docker-ce-rootless-extras + - docker-ce + - docker-scan-plugin + state: present diff --git a/project/roles/docker/tasks/packages_redhat.yml b/project/roles/docker/tasks/packages_redhat.yml new file mode 100644 index 0000000..11bdc6d --- /dev/null +++ b/project/roles/docker/tasks/packages_redhat.yml @@ -0,0 +1,26 @@ +--- +- name: Remove unwanted packages + ansible.builtin.yum: + name: + - docker + - docker-client + - docker-client-latest + - docker-common + - docker-latest + - docker-latest-logrotate + - docker-logrotate + - docker-engine + state: absent + +- name: Add repo + ansible.builtin.copy: + src: docker-ce.repo + dest: /etc/yum.repos.d/docker-ce.repo + +- name: Install packages + ansible.builtin.yum: + name: + - docker-ce + - docker-ce-cli + - docker-ce-rootless-extras + - docker-scan-plugin