aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/roles/docker/tasks/main.yml
blob: 26089f3677c2674bd0876095d0a34b0eda6bb388 (plain) (tree)
1
2
3
4
5
6
7
                       
                        



                                  



                                                          
                                                                                                 
                                                         
                                    
 


                                                                  
                      
                          
                                      
                  
 

                                     
                                     
                  
 




                                          
                            
                                
                       




                     
- name: Get host distro
  ansible.builtin.setup:
    gather_subset:
      - distribution
      - distribution_major_version
      - distribution_release
      - os_family

- name: Set platform-specific variables
  ansible.builtin.include_vars: "{{ __docker_vars_file }}"
  loop:
    - "{{ ansible_facts['os_family'] }}.yml"
    - "{{ ansible_facts['distribution'] }}.yml"
    - "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml"
  vars:
    __docker_vars_file: "{{ role_path }}/vars/{{ item }}"
  when: __docker_vars_file is exists

- name: Configure Docker logging driver
  when: docker_logging_driver is defined and docker_logging_driver
  ansible.builtin.include_tasks: logging.yml

- name: Install Docker
  become: true
  ansible.builtin.package:
    name: "{{ docker_package_names }}"
    state: present

- name: Enable & start Docker service
  become: true
  ansible.builtin.systemd_service:
    name: "{{ docker_service_name }}"
    enabled: true
    state: started

- name: Install module dependencies
  become: true
  ansible.builtin.package:
    name: "{{ docker_prune_module_deps }}"
    state: present

- name: Clean up Docker data
  become: true
  community.docker.docker_prune:
    builder_cache: true
    containers: true
    images: true
    images_filters:
      dangling: false
    networks: true
    volumes: true