The almost minimal example below works fine in ansible 1.7.2 but does not 
give same and expected result in 1.8.2.

In short what this script is doing is to increment a counter in the 
hosts_names.yml file whenever the variable system_upgrade equals 'True'.
This works fine with ansible 1.7.2 but on 1.8.2 a default value I use for 
the variable that should be used if the file hosts_names.yml doesn't exist 
partly take precedance over the value read from the file.

 The playbook is invoked with eighter of these two command lines:
ansible-playbook sample.yml -u msp --extra-vars "userid=msp 
system_upgrade=False"
ansible-playbook sample.yml -u msp --extra-vars "userid=msp 
system_upgrade=True"

If someone interested I can supply a tar file with the complete sample 
project.

---
  #
- hosts: 127.0.0.1
# user will be overridden by user from command line
  user: "{{ userid }}"
  gather_facts: no

  vars_files:
    - - "{{ hosts_names_vars_file }}"
      - "{{ default_hosts_names_vars_file }}"
    
  vars:
    #
    # Global System Configuration
    # 
    userid: root
    hosts_names_vars_file: "./hosts_names.yml"
    default_hosts_names_vars_file: "./default_hosts_names.yml"

  pre_tasks:
    - local_action: debug msg="Last deployment_index = {{ 
deployment_index_h | default(99) | int }}"

  roles:
     - { role: sample }

Output from first four times I  run on ansible 1.8.2, After that the same 
but with ansible 1.7.2:

ansible-playbook sample.yml -u msp --extra-vars "userid=msp 
system_upgrade=False"

PLAY [127.0.0.1] 
************************************************************** 
127.0.0.1: not importing file: /home/msp/error/hosts_names.yml

TASK: [debug msg="Last deployment_index = 99"] 
******************************** 
ok: [127.0.0.1 -> 127.0.0.1] => {
    "msg": "Last deployment_index = 99"
}

TASK: [sample | Generate hosts_names in current dir] 
************************** 
changed: [127.0.0.1 -> 127.0.0.1]

TASK: [sample | debug msg="Index = 3 0"] 
************************************** 
ok: [127.0.0.1] => {
    "msg": "Index = 3 0"
}

PLAY RECAP 
******************************************************************** 
127.0.0.1                  : ok=3    changed=1    unreachable=0    
failed=0   

msp@msp-precision-02:~/error$ 
ansible-playbook sample.yml -u msp --extra-vars "userid=msp 
system_upgrade=False"

PLAY [127.0.0.1] 
************************************************************** 

TASK: [debug msg="Last deployment_index = 99"] 
******************************** 
ok: [127.0.0.1 -> 127.0.0.1] => {
    "msg": "Last deployment_index = 0"
}

TASK: [sample | Generate hosts_names in current dir] 
************************** 
ok: [127.0.0.1 -> 127.0.0.1]

TASK: [sample | debug msg="Index = 3 0"] 
************************************** 
ok: [127.0.0.1] => {
    "msg": "Index = 3 0"
}

PLAY RECAP 
******************************************************************** 
127.0.0.1                  : ok=3    changed=0    unreachable=0    
failed=0   

ansible-playbook sample.yml -u msp --extra-vars "userid=msp 
system_upgrade=True"

PLAY [127.0.0.1] 
************************************************************** 

TASK: [debug msg="Last deployment_index = 99"] 
******************************** 
ok: [127.0.0.1 -> 127.0.0.1] => {
    "msg": "Last deployment_index = 0"
}

TASK: [sample | Generate hosts_names in current dir] 
************************** 
changed: [127.0.0.1 -> 127.0.0.1]

TASK: [sample | debug msg="Index = 3 0"] 
************************************** 
ok: [127.0.0.1] => {
    "msg": "Index = 3 0"
}

PLAY RECAP 
******************************************************************** 
127.0.0.1                  : ok=3    changed=1    unreachable=0    
failed=0   

ansible-playbook sample.yml -u msp --extra-vars "userid=msp 
system_upgrade=True"

PLAY [127.0.0.1] 
************************************************************** 

TASK: [debug msg="Last deployment_index = 99"] 
******************************** 
ok: [127.0.0.1 -> 127.0.0.1] => {
    "msg": "Last deployment_index = 1"
}

TASK: [sample | Generate hosts_names in current dir] 
************************** 
ok: [127.0.0.1 -> 127.0.0.1]

TASK: [sample | debug msg="Index = 3 0"] 
************************************** 
ok: [127.0.0.1] => {
    "msg": "Index = 3 0"
}

PLAY RECAP 
******************************************************************** 
127.0.0.1                  : ok=3    changed=0    unreachable=0    
failed=0   
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Same but with ansible 1.7.2
 ansible-playbook sample.yml -u msp --extra-vars "userid=msp 
system_upgrade=False"

PLAY [127.0.0.1] 
************************************************************** 
127.0.0.1: not importing file: /home/msp/error/hosts_names.yml

TASK: [debug msg="Last deployment_index = 99"] 
******************************** 
ok: [127.0.0.1 -> 127.0.0.1] => {
    "msg": "Last deployment_index = 99"
}

TASK: [sample | Generate hosts_names in current dir] 
************************** 
changed: [127.0.0.1 -> 127.0.0.1]

TASK: [sample | debug msg="Index = 3 0"] 
************************************** 
ok: [127.0.0.1] => {
    "msg": "Index = 3 0"
}

PLAY RECAP 
******************************************************************** 
127.0.0.1                  : ok=3    changed=1    unreachable=0    
failed=0  

ansible-playbook sample.yml -u msp --extra-vars "userid=msp 
system_upgrade=False"

PLAY [127.0.0.1] 
************************************************************** 

TASK: [debug msg="Last deployment_index = 0"] 
********************************* 
ok: [127.0.0.1 -> 127.0.0.1] => {
    "msg": "Last deployment_index = 0"
}

TASK: [sample | Generate hosts_names in current dir] 
************************** 
ok: [127.0.0.1 -> 127.0.0.1]

TASK: [sample | debug msg="Index = 2 0"] 
************************************** 
ok: [127.0.0.1] => {
    "msg": "Index = 2 0"
}

PLAY RECAP 
******************************************************************** 
127.0.0.1                  : ok=3    changed=0    unreachable=0    
failed=0   

ansible-playbook sample.yml -u msp --extra-vars "userid=msp 
system_upgrade=True"

PLAY [127.0.0.1] 
************************************************************** 

TASK: [debug msg="Last deployment_index = 0"] 
********************************* 
ok: [127.0.0.1 -> 127.0.0.1] => {
    "msg": "Last deployment_index = 0"
}

TASK: [sample | Generate hosts_names in current dir] 
************************** 
changed: [127.0.0.1 -> 127.0.0.1]

TASK: [sample | debug msg="Index = 2 0"] 
************************************** 
ok: [127.0.0.1] => {
    "msg": "Index = 2 0"
}

PLAY RECAP 
******************************************************************** 
127.0.0.1                  : ok=3    changed=1    unreachable=0    
failed=0  

ansible-playbook sample.yml -u msp --extra-vars "userid=msp 
system_upgrade=True"

PLAY [127.0.0.1] 
************************************************************** 

TASK: [debug msg="Last deployment_index = 1"] 
********************************* 
ok: [127.0.0.1 -> 127.0.0.1] => {
    "msg": "Last deployment_index = 1"
}

TASK: [sample | Generate hosts_names in current dir] 
************************** 
changed: [127.0.0.1 -> 127.0.0.1]

TASK: [sample | debug msg="Index = 3 1"] 
************************************** 
ok: [127.0.0.1] => {
    "msg": "Index = 3 1"
}

PLAY RECAP 
******************************************************************** 
127.0.0.1                  : ok=3    changed=1    unreachable=0    
failed=0  


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/44fb6b52-2529-419f-b18c-92a716307604%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to