Im trying to have ansible Update variable value base on OS distribution, but Im 
faling when I insert the rules in a template.
Any idea how to solve this?

---
- hosts: fansible,cansible
  vars:
    nagios_freebsd_load: -w 75,70,65 -c 90,85,80
    nagios_centos_load: -w 15,10,5 -c 30,25,20
    nagios_server_load: vars['nagios_{{ ansible_distribution|lower }}_load']
  tasks:
    - name: Print server load variable 
      debug: msg="{{ nagios_server_load }}"
    - name: Print server load variable 
      debug: var="{{ nagios_server_load }}"
    - name: Copying file
      template:
        src: ~/ansitrial/load.conf
        dest: /tmp/load.conf

cat ~/ansitrial/load.conf 
{{ nagios_server_load }}


TASK [Print server load variable] 
*******************************************************************************************************************************************
ok: [fansible] => {
    "msg": "vars['nagios_freebsd_load']"
}
ok: [cansible] => {
    "msg": "vars['nagios_centos_load']"
}

TASK [Print server load variable] 
*******************************************************************************************************************************************
ok: [fansible] => {
    "vars['nagios_freebsd_load']": "-w 75,70,65 -c 90,85,80"
}
ok: [cansible] => {
    "vars['nagios_centos_load']": "-w 15,10,5 -c 30,25,20"
}

TASK [Copying file] 
*********************************************************************************************************************************************************
changed: [cansible]
changed: [fansible]

PLAY RECAP 
******************************************************************************************************************************************************************
cansible                   : ok=4    changed=1    unreachable=0    failed=0   
fansible                      : ok=4    changed=1    unreachable=0    failed=0



remote@fansible:~ % cat /tmp/load.conf 
vars['nagios_freebsd_load']

[remote@cansible ~]$ cat /tmp/load.conf 
vars['nagios_centos_load']

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/62a93229-25e0-4d8d-ac3f-7b81dc9db26c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to