- name: Changing permission
  ansible.builtin.shell: 'chown -R admin. /share/docker_data/'
  become: true
  when: inventory_hostname in groups['raspberry'] or inventory_hostname in groups['raspberrypi5']
- name: Syncing all
  #ansible.builtin.shell: 'rsync -ra /share/docker_data/{mailu2,ha,gitlab,semaphore,webhub,nginx,heimdall} admin@192.168.77.238:/share/docker_data/'
  ansible.builtin.shell: 'ls -la'
  when: inventory_hostname in groups['nas']

- name: Get relevant configs
  ansible.builtin.shell: 'egrep -l  "# ha.sectorq.eu|# pw.sectorq.eu|# semaphore.sectorq.eu|# sectorq.eu|# gitlab.sectorq.eu|# ha.sectorq.eu" /share/docker_data/nginx/data/nginx/proxy_host/*'
  ignore_errors: yes
  become: yes
  register: result
  when: inventory_hostname in groups['raspberrypi5']

- debug:
    msg: "{{ result.stdout_lines  }}"
  when: inventory_hostname in groups['raspberrypi5']
- name: Replace ip
  ansible.builtin.lineinfile:
    path: "{{ item }}"
    regexp: '^\s+set \$server\s+\"\w+.\w+.\w+.\w+\";'
    line: "  set $server         \"192.168.77.238\";"
  become: yes
  with_items:
    - "{{ result.stdout_lines }}"
  when: inventory_hostname in groups['raspberrypi5']

