HI,

aws_ec2.yml -------->> dynamic inventory

---
plugin: aws_ec2
aws_access_key_id: 
aws_secret_access_key: 
filters:
 tag:CreatedBy: Terraform

################################################

httpd_installation.yml ---------->> playbook

---
 - name: Configure WebServer with Apache HTTPD
   hosts: aws_ec2
   become: yes
   vars:
           - package1: httpd
           - package2: firewalld
           - service1: httpd
           - service2: firewalld
           - myprotocol: httpd
           - myport: 80
           
   tasks:
           - name: Install webserver package
             yum:
                     name: "{{package1}}"
                     state: present
             notify: restart_httpd

           - name: Add custom port to httpd.conf
             lineinfile:
                     path: /etc/httpd/conf/httpd.conf
                     regexp: '^Listen'
                     insertafter: '^#Listen'
                     line: "Listen {{ myport }}"

           - name: Copy Webpage to document root
             copy:
                     src: index.html
                     dest: /var/www/html/index.html

           - name: Install firewall package
             yum:
                     name: "{{package2}}"
                     state: present

           - name: Start firewalld service
             service:
                     name: "{{service2}}"
                     state: started
                     enabled: yes

           - name: Allow httpd from firewall
             firewalld:
                     service: "{{myprotocol}}"
                     port: "{{myport}}/tcp"
                     permanent: yes
                     state: enabled
                     immediate: yes



On Wednesday, 13 October 2021 at 13:31:33 UTC+5:30 [email protected] wrote:

> Hard to give a useful answer without any actual code (playbooks, 
> inventory, etc)
>
> On Wed, 13 Oct 2021 at 08:47, Anirban Das <[email protected]> wrote:
>
>> Hi All,
>>
>> I'm trying to configure few ec2 instances using ansible, hence I created 
>> dynamic inventory in controller and playbook both. but I found that I need 
>> to pass private key where I'm little bit confused. 
>>
>> 1. Does Private key refer to key which is being used for ansible purpose 
>> or ec2 launching keypair?
>>
>> 2. Do I need to mention that private key path inside playbook?
>>
>> Please help me to get these answers. 
>>
>> Thanks,
>> Anirban Das
>>
>> -- 
>> 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/2dbd8161-36db-4203-9a7e-bfb3f63c3e1cn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/2dbd8161-36db-4203-9a7e-bfb3f63c3e1cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>

-- 
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/b97ac543-183c-4a26-9162-fe4f0fb71950n%40googlegroups.com.

Reply via email to