Hello,
not sure whether I understand your goal right. I assume you want to have
given group of tasks for each kind of server/host inside the same playbook.
One possibility would be to organize the playbook tasks inside different
blocks and have a hosts definition for each of these blocks. A, B can be
single hosts or groups from inventory.
---
- name: block A
hosts: A
tasks:
- name: T1 on a
debug:
msg: T1
- name: block B
hosts: B
tasks:
- name: T2 on b
debug:
msg: T2
- name: block common
hosts: all
tasks:
- name: T3
debug:
msg: T3
BR,
Roland
[email protected] schrieb am Donnerstag, 20. Mai 2021 um 18:43:17 UTC+3:
> Hello Anyone here can guide me on Ansible ?
> I have created a role for AEM(Adobe Experience Manager) Author and
> Publisher. They both have exact same instructions however as per role their
> variables do change. One server per role. One server cannot have two
> roles.
>
> Variable values are to be dictated by tag. We have two or more VM's but
> Ansible code should grab the value of the variable depending on tag. Has
> anyone done this before? If yes a code snippet or article would be
> appreciated.
>
> Example code snippet is below:
>
> - name: Create mnt directory structure
> file:
> path: /mnt/{{ item }}
> state: directory
> owner: cq5
> group: cq5
> mode: 775
> with_items:
> - crx
> - crx/author
> - crx/publish
> tags:
> - aem_author
> - aem_publish
>
> - name: Copy License file on Author
> copy:
> src: license.properties
> dest: "{{ item }}"
> owner: cq5
> group: cq5
> mode: 755
> force: yes
> loop:
> - "{{ author_folder }}"
> - "{{ publishe_folder }}"
> tags:
> - aem_author
> - aem_publish
>
> So as you see in the above snippet, looping variables should be fed as per
> server. If no tag is given then it should feed in the variable and in fact
> skip it.
>
> Is this possible at all?
> Thanks and Regards,
> Ameya Agashe
>
--
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/587c0f9e-6254-4f89-b508-ee93a59df7c9n%40googlegroups.com.