Hello everyone
I have a playbook called "play.yml" with three plays and I would like to
get the names of the roles that are applied to a certain host. Let's say I
have a host called host01 and this host is in the two groups: GROUP01 and
GROUP03
----------play.yml----------------
- name: play 1
hosts:
- GROUP01
roles:
- nginx
- php
- name: play 2
hosts:
- GROUP02
roles:
- mysql
- name: play 3
hosts:
- GROUP03
roles:
- linux
tasks:
- debug:
msg: "{{ ansible_role_names }}"
--------------------------------------------
I tried using the "role_names" magic variable but it didn't work as needed.
I run the playbook as follows
----------------------------------
ansible-playbook play.yml --limit host01
----------------------------------
So it will run on play 1 and play 3, so I wanted the "ansible_role_names"
variable to contain the values "nginx", "PHP" and "linux", but in my tests
it only shows the "linux" role. I thought about creating a variable and
adding the role names to the hostvars variable of host01 like
"hostvars['host01'][roles]" or something similar, but I wonder if there
isn't something ready already.
Thank you in advance.
--
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/CAOOzAW2srS_0tf7QnkbetN7fai%3DO87HJPwZHMjq-%2BW3-jM%2Bq9A%40mail.gmail.com.