Execution
Date 10 Sep 2024 17:28:28 +0100
Duration 00:02:13.50
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.4
ara 1.7.1 / 1.7.1
Python 3.10.10
Summary
139 Hosts
11 Tasks
1107 Results
3 Plays
11 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/create_imunify_plesk_inventory.yaml

---
- name: Delete file if exists and create header
  hosts: localhost
  gather_facts: false
  vars:
    inv_file: /home/ssh-gateway/ansible/kuly/plesk-imunify360-inv.ini
  tasks:
    - name: Delete inventory file if it exists
      ansible.builtin.file:
        path: "{{ inv_file }}"
        state: absent
      run_once: true
    - name: Create file and header
      ansible.builtin.lineinfile:
        path: "{{ inv_file }}"
        line: "[plesks]\n"
        create: true
        mode: '0644'
      run_once: true

- name: Generate plesk with imunify
  hosts: all
  gather_facts: false
  vars:
    inv_file: /home/ssh-gateway/ansible/kuly/plesk-imunify360-inv.ini
  roles:
    - plesk
    - imunify360
  tasks:
    - name: If plesk server add name to list
      when: plesk_found and imunify_found
      ansible.builtin.lineinfile:
        path: "{{ inv_file }}"
        line: "{{ inventory_hostname }}"
        insertafter: "[plesks]"
      delegate_to: localhost

- name: Add footer
  hosts: localhost
  gather_facts: false
  vars:
    inv_file: /home/ssh-gateway/ansible/kuly/plesk-imunify360-inv.ini
  tasks:
    - name: Add vars
      ansible.builtin.lineinfile:
        path: "{{ inv_file }}"
        line: |
          [plesks:vars]
          ansible_user=root
          ansible_port=2233
        insertafter: EOF
      run_once: true
      delegate_to: localhost