Dear Colleagues,

I'd like to be able to copy/template a file to a directory on a remote host 
depending upon the existence of the directory there (from a list of 
possible variants). Below I publish what I currently use but I hope there 
is a more scalable and elegant method, can you advise one?

  - name: check for new zabbix
    stat:
      path: /etc/zabbix/zabbix_agentd.d/
    register: newpath

  - name: check for old zabbix
    stat:
      path: /etc/zabbix/zabbix_agentd.conf.d/
    register: oldpath

  - name: copy consul userparameters for new zabbix
    when: newpath.stat.exists and newpath.stat.isdir
    template:
      src: files/consul-userparameter.conf.j2
      dest: /etc/zabbix/zabbix_agentd.d/consul.conf

  - name: copy consul userparameters for old zabbix
    when: oldpath.stat.exists and oldpath.stat.isdir
    template:
      src: files/consul-userparameter.conf.j2
      dest: /etc/zabbix/zabbix_agentd.conf.d/consul.conf


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/21c17b34-af80-480c-9cfb-c882b2c77efdn%40googlegroups.com.

Reply via email to