# Ansible roles and tasks

**URL:** <https://forum.ansible.com/t/ansible-roles-and-tasks/32268>\
**Category:** Ansible Project\
**Created:** [February 19, 2020, 9:51am UTC](https://forum.ansible.com/t/ansible-roles-and-tasks/32268 "2020-02-19T09:51:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amarnatha\_Reddy](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@Amarnatha\_Reddy](https://forum.ansible.com/u/Amarnatha_Reddy)\
**Post date:** [February 19, 2020, 9:51am UTC](https://forum.ansible.com/t/ansible-roles-and-tasks/32268/1 "2020-02-19T09:51:11Z")

</div>

Hi All,

I am planning to implement Ansible to do some tasks as per my requirement!  
Need ansible project structure guidance to process mix of roles and tasks.

Tasks:

1. Deploy the .zip file into server
2. After deploy clear cache on the server  
Task1: We are using CI/CD operations through jenkins , as part of build .zip files will be crated on jenkins server and using command/shell module deploy the artifacts based on selected environment (ex: qa1,qa2,etc…) from jenkins machine.  
Task2: After deployment same thing needs to trigger some command from jenkins to remote machine to clear the cache.

Inventory: For the first task hosts file is used with username/pwd via http method to connect remote servers and perform the commands

For the task2 we need to connect via ssh key (same command module)as servers are different.

So how can i write 2 tasks with hosts and roles for my requirement.

Thanks,  
Amaranth Polu

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 19, 2020, 11:38am UTC](https://forum.ansible.com/t/ansible-roles-and-tasks/32268/2 "2020-02-19T11:38:05Z")

</div>

What do you have so far?
