foreman-ansible-modules icon indicating copy to clipboard operation
foreman-ansible-modules copied to clipboard

Re-applying template inputs always results in 'changed'

Open Fodoj opened this issue 2 years ago • 0 comments

SUMMARY

Job template's inputs are showing dirty diff on every re-apply.

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible [core 2.11.4]
COLLECTION VERSION
2.2.0
KATELLO/FOREMAN VERSION
foreman-2.1.2.26-1
katello-3.16.0-1
STEPS TO REPRODUCE

Pass these as template inputs. In my case, its Ansible Playbook category, Ansible job provider:

    template_inputs:
      - name: noop_value
        input_type: user
        value_type: plain
        required: true
        description: value of noop
EXPECTED RESULTS

After initial apply, it does not report as "changed" on every run

ACTUAL RESULTS

Reports as changed, and shows "resource_type" field with "Katello::ActivationKey":

changed: [localhost] => (item=Puppet - Turn on/off noop) => {
    "ansible_loop_var": "item",
    "changed": true,
    "diff": {
        "after": {
            "job_templates": [
                {
                    "description_format": "Turn on/off noop",
                    "id": 197,
                    "job_category": "Ansible Playbook",
                    "location_ids": [
                        3
                    ],
                    "locked": false,
                    "name": "Puppet - Turn on/off noop",
                    "organization_ids": [
                        1
                    ],
                    "provider_type": "Ansible",
                    "snippet": false,
                    "template": "---\n- hosts: all\n  gather_facts: false\n\n  tasks:\n    - name: Block for updating puppet noop value on puppet.conf\n      become: true\n      block:\n        - name: Set noop option\n          lineinfile:\n            path: /etc/puppetlabs/puppet/puppet.conf\n            regexp: '^noop ='\n            line: noop = <%= input(\"noop_value\") -%>"
                }
            ],
            "template_inputs": [
                {
                    "advanced": false,
                    "description": "value of noop",
                    "fact_name": "",
                    "id": 92,
                    "input_type": "user",
                    "name": "noop_value",
                    "options": "",
                    "puppet_class_name": "",
                    "puppet_parameter_name": "",
                    "required": true,
                    "resource_type": "Katello::ActivationKey",
                    "value_type": "plain",
                    "variable_name": ""
                }
            ]
        },
        "before": {
            "job_templates": [
                {
                    "description_format": "Turn on/off noop",
                    "id": 197,
                    "job_category": "Ansible Playbook",
                    "location_ids": [
                        3
                    ],
                    "locked": false,
                    "name": "Puppet - Turn on/off noop",
                    "organization_ids": [
                        1
                    ],
                    "provider_type": "Ansible",
                    "snippet": false,
                    "template": "---\n- hosts: all\n  gather_facts: false\n\n  tasks:\n    - name: Block for updating puppet noop value on puppet.conf\n      become: true\n      block:\n        - name: Set noop option\n          lineinfile:\n            path: /etc/puppetlabs/puppet/puppet.conf\n            regexp: '^noop ='\n            line: noop = <%= input(\"noop_value\") -%>"
                }
            ],
            "template_inputs": [
                {
                    "description": "value of noop",
                    "fact_name": "",
                    "id": 92,
                    "input_type": "user",
                    "name": "noop_value",
                    "puppet_class_name": "",
                    "puppet_parameter_name": "",
                    "required": true,
                    "variable_name": ""
                }
            ]
        }
    },

Fodoj avatar Aug 25 '21 15:08 Fodoj