Automate you docker containers with ansible

---
- name: install pre-reqs
  apt:
    name: "{{item}}"
    state: present
  with_items:
    - "ca-certificates"
    - "curl"
    - "software-properties-common"

  

- name: docker repo key
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    state: present

- name: docker repo install
  apt_repository:
    repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
    state: present
    

- name: install docker
  apt: 
   name: docker-ce
   state: present
   update_cache: yes

- name: start service
  service:
    name: docker
    state: started
    enabled: true

- name: ensure docker-py is installed
  apt:
    name: "{{ item }}"
    state: present
  with_items:
    - "python-docker"
    - "python3-docker"

- name: add user to docker group
  user:
    name: ryan
    group: docker
    append: yes
---
- name:
  file:
      path: "{{ item }}"
      state: directory
  with_items:
    - ["/config", "/key", "/music", "/movies", "/pics", "/vids", "/tv" , "/weddingg_vids", ]
---
- name: Mount config  nfs 
  mount:
    path: /config
    src:  freenas:/mnt/tank/docker_host
    fstype: nfs
    state: mounted
- name: Mount key  nfs 
  mount:
    path: /key
    src:  freenas:/mnt/tank/key
    fstype: nfs
    state: mounted

- name: Mount music  nfs 
  mount:
    path: /music
    src:  freenas:/mnt/tank/music
    fstype: nfs
    state: mounted