freeipa / ansible-freeipa

Ansible roles and modules for FreeIPA
GNU General Public License v3.0
504 stars 231 forks source link

ipabackup - ipabackup_name parameter evaluation #1198

Open FF186 opened 10 months ago

FF186 commented 10 months ago

Experience error when I try to run ipabackup role twice.

Playbook:

pre_tasks:
    - ansible.builtin.find:
        path: /var/lib/ipa/backup
        file_type: directory
      register: _result

    - set_fact:
        _name: "{{ (_result.files | sort(attribute='path') | first).path }}"

  roles:
    - role: freeipa.ansible_freeipa.ipabackup
      vars:
        state: present

    - role: freeipa.ansible_freeipa.ipabackup
      when: _result.files | length > 5
      vars:
        ipabackup_name: "{{ _name }}"
        state: absent

Error message:

 FAILED! => {"changed": false, "msg": "ipabackup_name is given and state is not copied, restored or absent"}
FF186 commented 10 months ago

Works:

  roles:
    - {role: freeipa.ansible_freeipa.ipabackup, ipabackup_name: "{{ _name }}", state: absent}
    - {role: freeipa.ansible_freeipa.ipabackup, state: present}

Does not work:

  roles:
    - {role: freeipa.ansible_freeipa.ipabackup, state: present}
    - {role: freeipa.ansible_freeipa.ipabackup, ipabackup_name: "{{ _name }}", state: absent}
FF186 commented 10 months ago

I want to e.g backup only data, but a full backup is being made:

Creates full backup:

    - import_role:
        name: freeipa.ansible_freeipa.ipabackup
      vars:
          ipabackup_data: present
          state: present

Data backup fails: Even if the documentation says state: present is default.

    - import_role:
        name: freeipa.ansible_freeipa.ipabackup
      vars:
          ipabackup_data: present

FAILED! => {"changed": false, "msg": "ipabackup_name is given and state is not copied, restored or absent"}