Thanks,   That did what I needed.

On Monday, June 15, 2020 at 11:18:56 AM UTC+1, Ompragash wrote:
>
> Hi Mark,
>
> For your use-case, you can consider using Ansible magic variables 
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#accessing-information-about-other-hosts-with-magic-variables
>
> example:
>
> when: inventory_hostname in groups ['webserver']
>
> Regards,
> Ompragash
>
> On Mon, 15 Jun 2020 at 15:36, Mark Farrington <m.farri...@gmail.com 
> <javascript:>> wrote:
>
>> Hi,
>>
>> New to ansible and looking for advice.
>>
>> I have an action inside a task (I think that is correct terminology).
>>
>> Something like this:
>>
>>  - name: Cloudwatch deploy agent configuration for webserver
>>       template:
>>           src: templates/web-inst.json
>>           dest: "/opt/aws/amazon-cloudwatch-agent/bin/config.json"
>>           mode: 0644
>>       tags:
>>           - config
>>
>>
>>
>> The task is used to install AWS cloudwatch on web servers and this action 
>> is to just apply the config.   Now I want to extend this task to other 
>> types or servers (Lets say app server).
>> So I want to add another config action like this:
>>
>>  - name: Cloudwatch deploy agent configuration for App Server
>>       template:
>>           src: templates/app-inst.json
>>           dest: "/opt/aws/amazon-cloudwatch-agent/bin/config.json"
>>           mode: 0644
>>       tags:
>>           - config
>>
>> So, now I have two code blocks for configuration (One for each type of 
>> server).    How do I conditionally apply the correct config based on the 
>> host type?
>>
>> I currently execute it using the following command.  
>> ansible-playbook -i ../inventory/testinstance/ -l webserver playbook.yml 
>> --tags cloudwatch
>>
>> So, the idea is I would execute it with the appserver host instead like 
>> this:
>> ansible-playbook -i ../inventory/testinstance/ -l appserver playbook.yml 
>> --tags cloudwatch
>>
>> Think I can use the "when" statement to do this somehow?
>>
>> Any help would be greatly received. Alternatively, is this approach just 
>> nonsense and there is a better way?
>>
>>
>>
>>
>>
>> -- 
>> 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...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/2b0e6bcc-1197-4ade-bec6-b76a3c8a2da7o%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/2b0e6bcc-1197-4ade-bec6-b76a3c8a2da7o%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6cce3ce3-ab37-4d0a-8002-9906737b2f26o%40googlegroups.com.

Reply via email to