diff --git a/.ansible-lint b/.ansible-lint index f6ad8523..e68b5383 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -39,7 +39,6 @@ skip_list: - risky-file-permissions mock_roles: - - geerlingguy.docker - autoscaling mock_modules: diff --git a/emgb/emgb.yml b/emgb/emgb.yml index 5777b6a1..491a16cb 100644 --- a/emgb/emgb.yml +++ b/emgb/emgb.yml @@ -6,13 +6,6 @@ name: python-is-python3 state: present -- name: Install Docker role - include_role: - name: geerlingguy.docker - vars: - docker_users: - - ubuntu - docker_compose_package: docker-compose-plugin - name: Install yq ansible.builtin.shell: | diff --git a/generic/generic_pre_tasks.yml b/generic/generic_pre_tasks.yml index dd62de7f..975d95cc 100644 --- a/generic/generic_pre_tasks.yml +++ b/generic/generic_pre_tasks.yml @@ -45,3 +45,6 @@ ansible.builtin.apt: name: python3-pip state: latest + +- name: Setup Docker + ansible.builtin.import_tasks: ../generic/setup_docker.yml diff --git a/generic/setup_docker.yml b/generic/setup_docker.yml new file mode 100644 index 00000000..01a853be --- /dev/null +++ b/generic/setup_docker.yml @@ -0,0 +1,72 @@ +--- +- name: Update and upgrade all packages to the latest version + ansible.builtin.apt: + update_cache: true + upgrade: dist + cache_valid_time: 3600 +- name: Install required packages + + ansible.builtin.apt: + pkg: + - apt-transport-https + - ca-certificates + - curl + - gnupg + - software-properties-common + +- name: Create directory for Docker's GPG key + ansible.builtin.file: + path: /etc/apt/keyrings + state: directory + mode: "0755" + +- name: Add Docker's official GPG key + ansible.builtin.apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + keyring: /etc/apt/keyrings/docker.gpg + state: present + +- name: Print architecture variables + ansible.builtin.debug: + msg: "Architecture: {{ ansible_architecture }}, Codename: {{ ansible_lsb.codename }}" + +- name: Add Docker repository + ansible.builtin.apt_repository: + repo: >- + deb [arch={{ arch_mapping[ansible_architecture] | default(ansible_architecture) }} + signed-by=/etc/apt/keyrings/docker.gpg] + https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable + filename: docker + state: present + +- name: Install Docker and related packages + ansible.builtin.apt: + name: "{{ item }}" + state: present + update_cache: true + loop: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-buildx-plugin + - docker-compose-plugin + +- name: Add Docker group + ansible.builtin.group: + name: docker + state: present + +- name: Add user to Docker group + ansible.builtin.user: + name: "{{ ansible_user }}" + groups: docker + append: true + +- name: Enable and start Docker services + ansible.builtin.systemd: + name: "{{ item }}" + enabled: true + state: started + loop: + - docker.service + - containerd.service diff --git a/packer/requirements.yml b/packer/requirements.yml index 3a9f0384..f28a71b8 100644 --- a/packer/requirements.yml +++ b/packer/requirements.yml @@ -9,9 +9,6 @@ roles: - name: andrewrothstein.miniconda version: v6.4.0 - - name: geerlingguy.docker - version: 7.4.1 - - name: autoscaling src: https://github.com/deNBI/autoscaling-ansible version: 1.8.7