-
Couldn't load subscription status.
- Fork 167
Closed
Description
Here is an example of the problem:
user@h0$ ansible-playbook --version
ansible-playbook 2.1.0
config file = /home/user/ansible.cfg
configured module search path = Default w/o overrides
user@h0$ cat junos_install_config_example.pb.yaml
---
- name: Install config on edge3.lab
hosts: edge3.lab
connection: local
gather_facts: no
roles:
- Juniper.junos
tasks:
- name: Install config
junos_install_config:
host: "{{ inventory_hostname }}"
user: "user"
passwd: "user123"
replace: true
file: "./config.xml"
logfile: "./changes.log"
user@h0$ ansible-playbook junos_install_config_example.pb.yaml
PLAY [Install config on edge3.lab] *********************************************
TASK [Install config] **********************************************************
fatal: [edge3.lab]: FAILED! => {"changed": false, "failed": true, "msg": "value of replace must be one of: yes,on,1,true,1,True,no,off,0,false,0,False, got: True"}
NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit @/home/user/.ansible/retry/junos_install_config_example.pb.retry
PLAY RECAP *********************************************************************
edge3.lab : ok=0 changed=0 unreachable=0 failed=1
The problem is that Ansible 1.x considered this to be a valid definition of an argument:
module = AnsibleModule(
argument_spec=dict(
...
replace=dict(required=False, choices=BOOLEANS, default=False),
...
),
supports_check_mode=True)
In Ansible 2.x, the same declaration produces the error above.
However, if the argument is explicitly typed as a boolean it works both on Ansible 2.x and 1.x:
module = AnsibleModule(
argument_spec=dict(
...
replace=dict(required=False, type='bool', choices=BOOLEANS, default=False),
...
),
supports_check_mode=True)
Metadata
Metadata
Assignees
Labels
No labels