Comments (7)
@DWSR Thought you'd like to know that this thread inspired This PR, to fix default values in awx.awx as well. https://github.com/ansible/awx/pull/9313/files
from controller_configuration.
I'm not sure to follow you:
- all
tower_username
definitions are commented out in the defaults - the pattern for all tasks is
tower_username: "{{ tower_username | default(omit) }}"
(with only two exceptions, 'hosts' and 'users', defaulting to admin, but I'll fix this so that it's consistent). - and the same thing for
tower_oauthtoken
(without exception).
So, if you don't define the tower_...
variables in your inventory, the module should take them from the environment variables.
from controller_configuration.
Additionally, the tower_password
wasn't omitted on hosts
and users
, that might have caused more issues. I'll fix it also.
from controller_configuration.
Going to leave this open in case that did not solve it, plan to do some testing to verify for tower config file as well. Unless we hear back from @DWSR that the new revision worked, It has not been pushed to galaxy yet, but should be today once the other PR is merged.
from controller_configuration.
tower_username | default(omit)
will not omit the parameter if tower_username
is an empty string. In order to do that, you need to pass a second parameter of true
. Without that, the default values in several of the roles will cause credentials supplied in the environment (or via the config file, I suspect) to not work as expected.
An example:
- hosts: all
gather_facts: false
vars:
tower_username: ""
tasks:
- debug:
msg: "Without true: {{ tower_username | default(omit) }}"
- debug:
msg: "With true: {{ tower_username | default(omit, true) }}"
❯ ansible-playbook -i 'localhost,' ~/scratch/scratch.yml
PLAY [all] ****************************************************************************************************************************************************
TASK [debug] **************************************************************************************************************************************************
ok: [localhost] => {
"msg": "Without true: "
}
TASK [debug] **************************************************************************************************************************************************
ok: [localhost] => {
"msg": "With true: __omit_place_holder__0722bcf5e39a489bde9d47ecebed1d271e166a77"
}
PLAY RECAP ****************************************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
from controller_configuration.
I think the question rises, why is tower_username being set at all when your using ansible_cfg settings. I took your example and was wondering myself. We normally expect tower_username to be never declared, same with the other auth variables when ansible.cfg is being used.
Playbook:
- name: Launch VRF workflows
hosts: localhost
connection: local
gather_facts: false
vars:
tower_username: ""
tower_false: false
tower_true: true
tasks:
- debug:
msg: "tower_username Without true: {{ tower_username | default(omit) }}"
- debug:
msg: "tower_username With true: {{ tower_username | default(omit, true) }}"
- debug:
msg: "tower_not_username Without true: {{ tower_not_username | default(omit) }}"
- debug:
msg: "tower_not_username With true: {{ tower_not_username | default(omit, true) }}"
- debug:
msg: "tower_false Without true: {{ tower_false | default(omit) }}"
- debug:
msg: "tower_false With true: {{ tower_false | default(omit, true) }}"
- debug:
msg: "tower_true Without true: {{ tower_true | default(omit) }}"
- debug:
msg: "tower_true With true: {{ tower_true | default(omit, true) }}"
output:
ansible-playbook test_copy.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [Launch VRF workflows] ****************************************************************************************************************************************************************************
TASK [debug] *******************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "tower_username Without true: "
}
TASK [debug] *******************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "tower_username With true: __omit_place_holder__a5707b829bf711bc86fe36c4dfdc39ab701ebe3e"
}
TASK [debug] *******************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "tower_not_username Without true: __omit_place_holder__a5707b829bf711bc86fe36c4dfdc39ab701ebe3e"
}
TASK [debug] *******************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "tower_not_username With true: __omit_place_holder__a5707b829bf711bc86fe36c4dfdc39ab701ebe3e"
}
TASK [debug] *******************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "tower_false Without true: False"
}
TASK [debug] *******************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "tower_false With true: __omit_place_holder__a5707b829bf711bc86fe36c4dfdc39ab701ebe3e"
}
TASK [debug] *******************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "tower_true Without true: True"
}
TASK [debug] *******************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "tower_true With true: True"
}
PLAY RECAP *********************************************************************************************************************************************************************************************
localhost : ok=8 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
It is possible for someone to do a PR, and add false to every omit option in the Repo, and we would gladly accept that PR, but the quick fix for now is to not define the variable.
from controller_configuration.
@sean-m-sullivan It looks like 1.0.2
fixed this. I'll open up a separate issue to treat empty strings as unset (i.e. default(omit)
-> default(omit, true)
) so that discussion can be focused on that.
from controller_configuration.
Related Issues (20)
- Document the destroy_current_nodes option HOT 1
- filetree_create fails interacting with Ansible Tower HOT 5
- How to install AAP2.4 using automation HOT 2
- Should filetree_create export the credential with '$encrypted$' instead of ''? HOT 2
- Update requires_ansible key in `meta/runtime.yml` to supported Ansible versions HOT 1
- updating organisation name HOT 18
- filetree_create should output yamllint compatible truthy values HOT 3
- Controller group is removing/trying to remove constructed inventory groups HOT 2
- Ad_hoc value as role name should be adhoc in object diff HOT 1
- Verbosity on job template not changing back to 0 from higher values and state comes as OK HOT 6
- filetree_create/templates/current_inventory_sources.j2 complains about an undefined variable and fails. HOT 1
- `filetree_create` is exporting fields in settings with "null".
- controller_credentials password field-use another credential. HOT 5
- Web UI extra_vars fields default to JSON instead of YAML HOT 2
- Change default value for tags in workflows HOT 7
- AAP Config as Code Office Hours Agenda
- Add check_mode testing
- CI Failing HOT 2
- Creating/Updating too many job templates in parallel seems to be too much for controller API HOT 8
- Release pipeline fails - versions 2.8.x not available in galaxy HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from controller_configuration.