# 2023-09-25 # Tasks: docker --- - ansible.builtin.include_vars: docker.yml # # Prepare Docker service # - name: Create directories ansible.builtin.file: path: "{{ item }}" owner: root group: root state: directory mode: u=rwx,g=rx,o=rx with_items: "{{ directories_create }}" when: - ansible_facts['system'] == "Linux" tags: - system - directories - create - name: Process daemon.json template ansible.builtin.template: backup: true src: "{{ vm_template_daemon_json }}" dest: "{{ vm_daemon_json_root }}/{{ vm_template_daemon_json_name }}" owner: root group: root mode: u=rw,g=r,o=r when: - ansible_facts['system'] == "Linux" tags: - template - docker - daemon - add - name: Process override.conf template ansible.builtin.template: backup: true src: "{{ vm_template_docker_override }}" dest: "{{ vm_docker_override_root }}/{{ vm_template_docker_override_name }}" owner: root group: root mode: u=rw,g=r,o=r when: - ansible_facts['system'] == "Linux" tags: - template - docker - override - add # # Install Docker # - name: Setup Docker's GPG ansible.builtin.shell: | install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg chmod a+r /etc/apt/keyrings/docker.gpg when: - ansible_facts['system'] == "Linux" - ansible_facts['os_family'] == "Debian" tags: - docker - gpg - name: Add Docker repository ansible.builtin.shell: | echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null when: - ansible_facts['system'] == "Linux" - ansible_facts['os_family'] == "Debian" tags: - docker - repositories - name: Perform Docker packages cleanup ansible.builtin.package: state: absent name: "{{ docker_pakages_cleanup }}" when: - ansible_facts['system'] == "Linux" tags: - apt - packages - remove - docker - name: Install Docker packages ansible.builtin.package: install_recommends: false update_cache: true name: "{{ docker_pakages_required + docker_pakages_needed }}" when: - ansible_facts['system'] == "Linux" tags: - apt - packages - add - docker - name: Reload daemons ansible.builtin.systemd: daemon_reload: true when: - ansible_facts['system'] == "Linux" tags: - system - services - reload - name: Ensure Docker is restarted ansible.builtin.service: name: "{{ item }}" state: restarted with_items: "{{ docker_services }}" when: - ansible_facts['system'] == "Linux" tags: - services - docker - start - name: Install Grafana Loki Docker plugin community.docker.docker_plugin: plugin_name: "{{docker_loki_image}}:{{ docker_loki_version }}" alias: "{{ docker_loki_alias }}" state: enable when: - ansible_facts['system'] == "Linux" tags: - services - docker - plugins