Hi all,
I am trying to set a new host fact (is_master, is_slave) based on comparison of a pre-assigned variable and ansible_hostname fact.
group_vars/
master_hostname: host1
slave_hostname: host2
Tasks
- name: Set master host fact
set_fact:
is_master: yes
when: master_hostname == ansible_hostname
- name: Set slave host fact
set_fact:
is_slave: yes
when: slave_hostname == ansible_hostname
- name: copy master configuration file
template:
src: master.j2
dest: /etc/master.conf
when: is_master == True
- name: copy slave configuration file
template:
src: slave.j2
dest: /etc/slave.conf
when: is_slave == True
TASK [Gathering Facts] *********************************************************
ok: [host1]
ok: [host2]
TASK [Set is_master variable] ***************************************
ok: [host1]
skipping: [host1]
TASK [Set is_slave variable] ****************************************
skipping: [host2]
ok: [host2]
The goal I am trying to reach is to run certain tasks depending whether the host is master or slave. But these set_fact tasks always get skipped even though condition should be true. Really appreciate your help in pointing out what I am doing wrong.
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b4039197-4934-4bc4-94ef-40996b6fde06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/697Ke5ficy0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@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/CACVha7eMHd%2BWdX4fBtKwfHABZHkF8nf-sLYhu9GZTz3QEY3M7Q%40mail.gmail.com.