Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tower Settings of type on/off idempotency not working #14487

Closed
5 of 11 tasks
Dustin-Wi opened this issue Sep 28, 2023 · 6 comments · Fixed by #14489
Closed
5 of 11 tasks

Tower Settings of type on/off idempotency not working #14487

Dustin-Wi opened this issue Sep 28, 2023 · 6 comments · Fixed by #14489
Labels
community component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug

Comments

@Dustin-Wi
Copy link

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX is open source software provided for free and that I might not receive a timely response.
  • I am NOT reporting a (potential) security vulnerability. (These should be emailed to [email protected] instead.)

Bug Summary

When trying to set the setting named AWX_MOUNT_ISOLATED_PATHS_ON_K8S to true, no matter what I put in the playbook it is always marked as "changed: true", even if the setting is already true..

Sample Task:

    - name: SET AWX EXPOSE HOST PATHS
      awx.awx.settings:
        name: "AWX_MOUNT_ISOLATED_PATHS_ON_K8S"
        value: true

When I change the playbook value and register the results of the task to review the results I get this:

Value In Playbook Resulting Debug
true ok: [awxlab] => {
"this_setting": {
"changed": true,
"failed": false,
"new_values": {
"AWX_MOUNT_ISOLATED_PATHS_ON_K8S": "True"
},
"old_values": {
"AWX_MOUNT_ISOLATED_PATHS_ON_K8S": true
},
"value": true
}
}
True ok: [awxlab] => {
"this_setting": {
"changed": true,
"failed": false,
"new_values": {
"AWX_MOUNT_ISOLATED_PATHS_ON_K8S": "True"
},
"old_values": {
"AWX_MOUNT_ISOLATED_PATHS_ON_K8S": true
},
"value": true
}
}
"true" ok: [awxlab] => {
"this_setting": {
"changed": true,
"failed": false,
"new_values": {
"AWX_MOUNT_ISOLATED_PATHS_ON_K8S": "true"
},
"old_values": {
"AWX_MOUNT_ISOLATED_PATHS_ON_K8S": true
},
"value": true
}
}
"True" ok: [awxlab] => {
"this_setting": {
"changed": true,
"failed": false,
"new_values": {
"AWX_MOUNT_ISOLATED_PATHS_ON_K8S": "True"
},
"old_values": {
"AWX_MOUNT_ISOLATED_PATHS_ON_K8S": true
},
"value": true
}
}
yes ok: [awxlab] => {
"this_setting": {
"changed": true,
"failed": false,
"new_values": {
"AWX_MOUNT_ISOLATED_PATHS_ON_K8S": "True"
},
"old_values": {
"AWX_MOUNT_ISOLATED_PATHS_ON_K8S": true
},
"value": true
}
}

The documentation says this:


        Modify Automation Platform Controller settings. See https://www.ansible.com/tower for an overview.

OPTIONS (= is mandatory):
- value
        Value to be modified for given setting.
        **If given a non-string type, will make best effort to cast it to type API expects.**
        For better control over types, use the `settings' param instead.
        default: null
        type: str

This leads me to believe that the logic used to sanitize the input might be doing a little extra or the conversion of 'settings' parameters to/from name/value parameters.

The documentation does show an example of how to use both the settings parameter and the name/value parameter. So, this may be lower priority but I wanted to get this somewhere that could be search by others who may be running into this issue.

AWX version

23.1.0

Select the relevant components

  • UI
  • UI (tech preview)
  • API
  • Docs
  • Collection
  • CLI
  • Other

Installation method

kubernetes

Modifications

no

Ansible version

2.15.4

Operating system

CentOS Stream release 9

Web browser

Firefox

Steps to reproduce

Use a playbook that modifies a boolean setting.
Use the awx.awx.setting module.
Use the name/value parameters instead of the settings paremeter.
Sample:

    - name: SET AWX EXPOSE HOST PATHS
      awx.awx.settings:
        name: "AWX_MOUNT_ISOLATED_PATHS_ON_K8S"
        value: true
      register: this_setting
    
    - name: Debug this setting
      debug: var=this_setting

Expected results

When the setting is already true, idempotency keeps the playbook from trying to update the setting again.

Actual results

Regardless if the setting is true or not, the playbook always updates the setting.

Additional information

No response

@github-actions github-actions bot added component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug community labels Sep 28, 2023
@kurokobo
Copy link
Contributor

kurokobo commented Sep 28, 2023

As documented, settings param is recommended for non-string types settings.

For better control over types, use the `settings' param instead.

So try this out:

    - name: SET AWX EXPOSE HOST PATHS
      awx.awx.settings:
        settings:
          AWX_MOUNT_ISOLATED_PATHS_ON_K8S: true
      register: this_setting

@Dustin-Wi
Copy link
Author

This is what I ended up doing and it works.

I realize this may not be the most important issue for an open source project of this size, and I wasn't sure if this was intended behavior. So, I reported it.

Thank you,

Dustin

@kurokobo
Copy link
Contributor

Oh, you already mentioned about settings param in the first post, my apologies.

I've made investigate a bit and found that this is an unintended behavior indeed, so I'll send PR to address this.

kurokobo added a commit to kurokobo/awx that referenced this issue Sep 30, 2023
kurokobo added a commit to kurokobo/awx that referenced this issue Sep 30, 2023
AlanCoding added a commit that referenced this issue Sep 30, 2023
@Dustin-Wi
Copy link
Author

Sorry to harass further, but how do I implement the update? I tried installing the collection again using ansible-galaxy but it's telling me that I already have the latest version of the collection? Do these updates and patches get pushed on sprint cycles or something?

@kurokobo
Copy link
Contributor

kurokobo commented Oct 1, 2023

@Dustin-Wi
The fix will be shipped with the next version of AWX. You should just wait for the next release, or if you want to use before its release, you can install it from git repository.

CLI:

ansible-galaxy collection install git+https://github.com/ansible/awx.git,devel

or by requirements.yml:

collections:
  - name: https://github.com/ansible/awx.git
    type: git
    version: devel

@Dustin-Wi
Copy link
Author

@kurokobo Thank you!

djyasin pushed a commit to djyasin/awx that referenced this issue Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants