Skip to content

Commit

Permalink
Merge pull request #14 from arnavrneo/dev
Browse files Browse the repository at this point in the history
[merge]
  • Loading branch information
arnavrneo authored Mar 27, 2024
2 parents 00950df + 988c3b8 commit 712f397
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
45 changes: 45 additions & 0 deletions url-shortener/playbook/ec2_playbook.yaml
Original file line number Diff line number Diff line change
@@ -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
...
5 changes: 2 additions & 3 deletions url-shortener/playbook/roles/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
<Will show connection to AWS EC2>

- hosts: servers
roles:
Expand Down

0 comments on commit 712f397

Please sign in to comment.