<commit_before>---

# file: playbooks/roles/common/tasks/docker.yml

# Good starting point: https://github.com/angstwad/docker.ubuntu

- name: remove conflicting Docker packages (Debian family)
  apt: pkg={{ item }} state=absent
  with_items:
    - docker
    # - docker-engine
    - docker.io
  environment:
    DEBIAN_FRONTEND: noninteractive
  when: ansible_os_family == "Debian"
  tags: [ docker ]

- name: Install linux-image-extra-* packages to enable AuFS driver
  apt: pkg={{ item }} state=present
  with_items:
    - linux-image-extra-{{ ansible_kernel }}
    - linux-image-extra-virtual
  when: ansible_os_family == "Debian" and ansible_distribution_version|version_compare('14.04', '==')
  register: linux_image_extra_install
  ignore_errors: yes
  tags: [ docker ]

- name: Docker apt-key (Debian family)
  apt_key: id="<KEY>" keyserver="hkp://p80.pool.sks-keyservers.net:80" state=present
  when: ansible_os_family == "Debian"
  register: add_repository_key
  ignore_errors: yes
  tags: [ docker ]

- name: Docker apt-key (Debian family) | Alternative
  shell: "curl -sSL {{ apt_key_url }} | sudo apt-key add -"
  when: add_repository_key|failed
  tags: [ docker ]

- name: docker repo (Debian family)
  apt_repository: repo="deb https://apt.dockerproject.org/repo {{ ansible_lsb.id|lower }}-{{ ansible_lsb.codename|lower }} main" update_cache=yes
  when: ansible_os_family == "Debian"
  tags: [ docker ]

- name: docker packages (Debian family)
  apt: pkg={{ item }} update_cache=yes state=latest
  with_items:
    - docker-engine
  when:
    - ansible_os_family == "Debian"
  tags: [ docker ]

- name: Add users to the docker group
  user:
    name: "{{ item }}"
    groups: docker
    append: yes
  with_items: "{{ conf_docker_group_members }}"
  when: conf_docker_group_members is defined

- name: provision configs (Debian family)
  template: src=etc/{{ item }}.j2 dest={{ conf_local_etc_path }}/{{ item }} owner=root group={{ conf_root_group }} mode=0644
  with_items:
      - default/docker
  when:
    - ansible_os_family == "Debian"
  notify: handle_restart_docker
  tags: [ docker, docker-conf ]

- name: provision service (Debian family)
  template: src=lib/{{ item }}.j2 dest=/lib/{{ item }} owner=root group={{ conf_root_group }} mode=0644
  with_items:
      - systemd/system/docker.service
  when:
    - ansible_os_family == "Debian"
  notify: handle_restart_docker
  tags: [ docker, docker-conf ]
  <commit_msg>Initial support for containers.<commit_after>---

# file: playbooks/roles/common/tasks/docker.yml

# Good starting point: https://github.com/angstwad/docker.ubuntu

# Containers
#
#   - Create /var/lib/appflow/

- name: python-pip (Debian family)
  apt: pkg={{ item }} state=present
  with_items:
    - python-pip
  environment:
    DEBIAN_FRONTEND: noninteractive
  when: ansible_os_family == "Debian"
  tags: [ docker ]

- name: install docker-py (pip3)
  pip: name={{ item }} executable=pip3 state=present
  with_items:
    - docker-py
  tags: [ docker ]

- name: install docker-py (pip)
  pip: name={{ item }} state=present
  with_items:
    - docker-py
  tags: [ docker ]

- name: remove conflicting Docker packages (Debian family)
  apt: pkg={{ item }} state=absent
  with_items:
    - docker
    # - docker-engine
    - docker.io
  environment:
    DEBIAN_FRONTEND: noninteractive
  when: ansible_os_family == "Debian"
  tags: [ docker ]

- name: Install linux-image-extra-* packages to enable AuFS driver
  apt: pkg={{ item }} state=present
  with_items:
    - linux-image-extra-{{ ansible_kernel }}
    - linux-image-extra-virtual
  when: ansible_os_family == "Debian" and ansible_distribution_version|version_compare('14.04', '==')
  register: linux_image_extra_install
  ignore_errors: yes
  tags: [ docker ]

- name: Docker apt-key (Debian family)
  apt_key: id="<KEY>" keyserver="hkp://p80.pool.sks-keyservers.net:80" state=present
  when: ansible_os_family == "Debian"
  register: add_repository_key
  ignore_errors: yes
  tags: [ docker ]

- name: Docker apt-key (Debian family) | Alternative
  shell: "curl -sSL {{ apt_key_url }} | sudo apt-key add -"
  when: add_repository_key|failed
  tags: [ docker ]

- name: docker repo (Debian family)
  apt_repository: repo="deb https://apt.dockerproject.org/repo {{ ansible_lsb.id|lower }}-{{ ansible_lsb.codename|lower }} main" update_cache=yes
  when: ansible_os_family == "Debian"
  tags: [ docker ]

- name: docker packages (Debian family)
  apt: pkg={{ item }} update_cache=yes state=latest
  with_items:
    - docker-engine
  when:
    - ansible_os_family == "Debian"
  tags: [ docker ]

- name: Add users to the docker group
  user:
    name: "{{ item }}"
    groups: docker
    append: yes
  with_items: "{{ conf_docker_group_members }}"
  when: conf_docker_group_members is defined

- name: provision configs (Debian family)
  template: src=etc/{{ item }}.j2 dest={{ conf_local_etc_path }}/{{ item }} owner=root group={{ conf_root_group }} mode=0644
  with_items:
      - default/docker
  when:
    - ansible_os_family == "Debian"
  notify: handle_restart_docker
  tags: [ docker, docker-conf ]

- name: provision service (Debian family)
  template: src=lib/{{ item }}.j2 dest=/lib/{{ item }} owner=root group={{ conf_root_group }} mode=0644
  with_items:
      - systemd/system/docker.service
  when:
    - ansible_os_family == "Debian"
  notify: handle_restart_docker
  tags: [ docker, docker-conf ]

- name: provision docker containers
  docker_container:
    name: "{{ item.key }}"
    state: "{{ item.value.state }}"
    image: "{{ item.value.image }}"
    restart_policy: "{{ item.value.restart_policy }}"
    published_ports: "{{ item.value.published_ports|default([]) }}"
    volumes: "{{ item.value.volumes|default([]) }}"
  with_dict: '{{ conf_docker_containers }}'
  ignore_errors: yes
  tags: [ docker, docker-conf, containers ]
{'fraction_non_alphanumeric': 0.1349409953822473, 'fraction_numerical': 0.006499059346673508, 'mean_word_length': 3.8131687242798353, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5311112', 'n_tokens_mistral': 2145, 'n_tokens_neox': 2000, 'n_words': 468}