---
- name: Create Directory If It Doesn't Exist
  file:
    path: "{{ item }}"
    state: directory
    mode: 0755
  with_items:
    - /root/oopp_level_1
    - /root/oopp_level_2
  tags: limao_proxy

- name: Define Server_config 1 
  template: src=server_config.json dest=/root/oopp_level_1/server_config.json  owner=root group=root mode=0644
  tags: limao_proxy

- name: Define Server_config 2
  vars:
    sec: True
  template: src=server_config.json dest=/root/oopp_level_2/server_config.json  owner=root group=root mode=0644 
  tags: limao_proxy 

- name: Stop And Reomove All Container
  docker_container:
    name: "{{ item }}"
    state: absent
  with_items:
    - oopp-file-1
    - oopp-file-2
  ignore_errors: True
  tags: limao_proxy


- name: Start All Container
  shell: "{{ item }}"
  with_items:
    - docker run --name oopp-file-1 -d  --restart "always" --log-opt max-size=3m --log-opt max-file=50  -v /root/oopp_level_1:/oopp_data -p 8388:8388 -p 8389:8389 oopp:1.0 oopp --config_file=/oopp_data/server_config.json
    - docker run --name oopp-file-2 -d  --restart "always" --log-opt max-size=3m --log-opt max-file=50  -v /root/oopp_level_2:/oopp_data -p 8488:8488 -p 8489:8489 oopp:1.0 oopp --config_file=/oopp_data/server_config.json
  tags: limao_proxy
