- name: gather facts
  setup:
    gather_subset:
      - min


- name: set timezone
  timezone:
    name: "{{ timezone }}"
  notify: restart crond


- name: flush handlers to force restart of crond
  meta: flush_handlers


- name: enable auto reboot on kernel panic
  copy:
    dest: /etc/sysctl.d/90-auto-reboot.conf
    content: "kernel.panic = 5\n"
    mode: 0644


- name: upgrade packages
  include_tasks: upgrade.yml


- name: install and configure docker
  include_tasks: install_docker.yml


- name: create root container dirs
  file:
    path: "{{ item }}"
    state: directory
  loop:
    - "{{ container_config_dir }}"
    - "{{ container_logs_dir }}"
    - "{{ container_root_build_dir }}"


- name: create child container dirs
  file:
    path: "{{ item }}"
    state: directory
  loop: "{{ [container_config_dir, container_logs_dir] | product(groups['containers'] | d([])) | map('join', '/') }}"
