ansible-plugin
ansible-plugin copied to clipboard
Boolean extra variables being interpreted as Strings
Jenkins and plugins versions report
Environment
Jenkins: 2.413
OS: Linux - 5.15.0-76-generic
Java: 11.0.19 - Ubuntu (OpenJDK 64-Bit Server VM)
---
ansible:240.vc26740a_625c0
The only way Ansible can detect boolean extra-variables is by passing JSON using the extras
parameter, like shown below.
Otherwise, they are interpreted as Strings.
ansiblePlaybook(
playbook: './src/main.yml',
extras: '''
--extra-vars "{bar: false}"
'''
)
Equivalent when using the terminal:
$ ansible-playbook playbook.yml --extra-vars "{bar: false}"
What Operating System are you using (both controller, and any agents involved in the problem)?
Alpine Docker container running Ansible.
Reproduction steps
- Declare a variable in Ansible that should default to a different value if extra variable is given as
false
:
foo: "{{ bar | default(99, true) }}"
- Run the script through Jenkins:
ansiblePlaybook(
playbook: './src/main.yml',
extraVars: [
'bar': false
]
)
Expected Results
foo: 99
Actual Results
foo: "false"
I don't think passing JSON --extra-vars was ever supported on the plugin. Feel free to submit a PR
I've edited the issue to make it more clear. If I find some free time I will be submitting a PR, thank you. 🙂
@Pexers Any plan on adding this enhancement to Jenkin's ansible plugin?
@mehulgogri I will give it a shot for sure, thanks for the reminder!