aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/roles/docker/tasks/logging.yml
blob: b40da1893663d399df16dfc484769aa60ad1146c (plain) (tree)
1
2
3
4
5
6
7
8
9
10





                                    
                                     


                               
                                                                                            


                                  
                                 




                                 
                                                                                                          


               
                        
- name: Read Docker config
  block:
    - name: Read daemon.json
      become: true
      ansible.builtin.slurp:
        src: /etc/docker/daemon.json
      register: docker_current_config

    - name: Parse daemon.json
      ansible.builtin.set_fact:
        docker_current_config: '{{ docker_current_config.content | b64decode | from_json }}'
  rescue:
    - name: daemon.json is missing
      ansible.builtin.set_fact:
        docker_current_config: {}

- name: Modify Docker config
  become: true
  ansible.builtin.copy:
    dest: /etc/docker/daemon.json
    content: '{{ docker_current_config | combine({"log-driver": docker_logging_driver}) | to_nice_json }}'
    owner: root
    group: root
    mode: '644'
  notify: docker_restart