From f91be2ce5258c1b72636096c75d3d7b75221b66b Mon Sep 17 00:00:00 2001 From: Arnav <48650781+arnavrneo@users.noreply.github.com> Date: Tue, 26 Mar 2024 22:14:03 +0530 Subject: [PATCH 1/3] update/README --- url-shortener/playbook/roles/docker/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/url-shortener/playbook/roles/docker/README.md b/url-shortener/playbook/roles/docker/README.md index 209957d..701f956 100644 --- a/url-shortener/playbook/roles/docker/README.md +++ b/url-shortener/playbook/roles/docker/README.md @@ -13,10 +13,9 @@ Role Variables To change the directory on the remote servers where script should be copied, edit the `script_dest` in `main.yml` under `vars` directory. -Example Playbook +Configure Hosts ---------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + - hosts: servers roles: From de6c1420f4f6924b549ccb9d020095efe3a34687 Mon Sep 17 00:00:00 2001 From: Arnav <48650781+arnavrneo@users.noreply.github.com> Date: Tue, 26 Mar 2024 22:15:50 +0530 Subject: [PATCH 2/3] update/README --- url-shortener/playbook/roles/docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/url-shortener/playbook/roles/docker/README.md b/url-shortener/playbook/roles/docker/README.md index 701f956..6a4b23f 100644 --- a/url-shortener/playbook/roles/docker/README.md +++ b/url-shortener/playbook/roles/docker/README.md @@ -15,7 +15,7 @@ To change the directory on the remote servers where script should be copied, edi Configure Hosts ---------------- - + - hosts: servers roles: From 988c3b8a1755cf4b055b9c3bb36908c6c5ffdef1 Mon Sep 17 00:00:00 2001 From: Arnav <48650781+arnavrneo@users.noreply.github.com> Date: Wed, 27 Mar 2024 22:56:04 +0530 Subject: [PATCH 3/3] feat/playbook-ec2 --- url-shortener/playbook/ec2_playbook.yaml | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 url-shortener/playbook/ec2_playbook.yaml diff --git a/url-shortener/playbook/ec2_playbook.yaml b/url-shortener/playbook/ec2_playbook.yaml new file mode 100644 index 0000000..6473600 --- /dev/null +++ b/url-shortener/playbook/ec2_playbook.yaml @@ -0,0 +1,45 @@ +--- +- + hosts: localhost + connection: local + gather_facts: false + + tasks: + - name: Create a SG for SSH & HTTP access + amazon.aws.ec2_security_group: + name: ansible + description: Ansible SG + region: us-east-1 + vpc_id: vpc-0353f47c70b42ca4d + rules: + - proto: tcp + from_port: 80 + to_port: 80 + cidr_ip: 0.0.0.0/0 + - proto: tcp + from_port: 22 + to_port: 22 + cidr_ip: 0.0.0.0/0 + + - name: Provision an instance + amazon.aws.ec2_instance: + key_name: ansible + instance_type: t2.micro + image_id: ami-0c101f26f147fa7fd + region: us-east-1 + wait: true + exact_count: 1 + tags: + Ansible: AnsibleNginxWebServers + register: ec2 + + - name: Add all instance public IPs to host group + ansible.builtin.add_host: + hostname: "{{ item.public_ip_address }}" + groups: ansiblehosts + with_items: "{{ ec2.instances }}" + + - name: Show group + debug: + var: groups.ansiblehosts +...