Hi,

the way I understand it you want your Playbook to only copy the 
license.properties file to the location in `author_folder` if the tag 
`aem_author` is specified und to the location `publishe_folder` when the 
playbook is invoked with the `aem_publish` tag?

If this is the case then I think the most common way would be to always 
copy to the location specified in a variable `dest_folder` which is set per 
host or group in your inventory. 
If for some reason you have to be able to set it via tags, than I would 
probably would use `set_fact` in combination with tags to specify the 
variable content accordingly:

- name: Set destination for Author
  set_fact:
    dest_folder:  "{{ author_folder }}"
  tags:
    - aem_author

- name: Set destination for Publisher
  set_fact:
    dest_folder:  "{{ publishe_folder }}"
  tags:
    - aem_publish

- name: Copy License file on Author
  copy:
    src: license.properties
    dest: "{{ dest_folder }}"
    owner: cq5
    group: cq5
    mode: 755
    force: yes
  tags:
    - aem_author
    - aem_publish

This would probably work but I feel that this really the wrong way to do it 
unless you have a really specific need.

Cheers,
André
On Friday, May 21, 2021 at 7:05:52 AM UTC+2 [email protected] wrote:

> 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/4d1d25cc-a88b-4f85-a331-6436650ff8e1n%40googlegroups.com.

Reply via email to