diff --git a/docker.yml b/docker.yml new file mode 100644 index 0000000..b2aba0c --- /dev/null +++ b/docker.yml @@ -0,0 +1,82 @@ +--- +- name: Install Docker on Ubuntu + hosts: all + remote_user: chiefsoft # Change remote user to your sudo user! + become: true + vars: + arch_mapping: # Map ansible architecture {{ ansible_architecture }} names to Docker's architecture names + x86_64: amd64 + aarch64: arm64 + + tasks: + - 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/install_apache.yml b/install_apache.yml new file mode 100644 index 0000000..d6b5fb0 --- /dev/null +++ b/install_apache.yml @@ -0,0 +1,13 @@ +--- + +- hosts: all + become: true + tasks: + + - name: upfate repository index + apt: + update_cache: yes + + - name: install apahce2 package + apt: + name: apache2