Skip to content

Commit b0e6c36

Browse files
committed
ansible roles and tasks
1 parent 369ad21 commit b0e6c36

File tree

9 files changed

+116
-1
lines changed

9 files changed

+116
-1
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Run playbook
2+
3+
```bash
4+
ansible-playbook --inventory inventory/ansible-import-roles-playbook/hosts ansible-import-roles-playbook.yml
5+
```
6+
7+
8+
## How to find apache is installed or not
9+
10+
```
11+
type -a apache2
12+
```
13+
14+
15+
## SSH to EC2 instance
16+
17+
```
18+
ssh -i /Users/rahulwagh/.ssh/aws_ec2_terraform [email protected]
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
- name: Example Ansible playbook for Handlers
3+
hosts: all
4+
become: yes
5+
remote_user: ubuntu
6+
roles:
7+
- custom-role
8+
- install-apache
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[default]
2+
ec2-3-72-2-115.eu-central-1.compute.amazonaws.com ansible_ssh_private_key_file=/Users/rahulwagh/.ssh/aws_ec2_terraform
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- import_tasks: packages.yml
3+
- import_tasks: message.yml
4+
- name: Start nginx service
5+
service:
6+
name: nginx
7+
state: started
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- name: Set message file
3+
copy:
4+
content: "{{ message }}"
5+
dest: /var/www/html/index.html
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Install required packages
3+
apt:
4+
name:
5+
- nginx
6+
- git
7+
- curl
8+
state: latest
9+
update_cache: yes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
message: "Hello, world!"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- name: Install Apache web server
3+
become: yes
4+
apt:
5+
name: lighttpd
6+
state: latest
7+
update_cache: yes
8+
9+
- name: Update Lighttpd configuration
10+
lineinfile:
11+
path: /etc/lighttpd/lighttpd.conf
12+
regexp: '^server.port = 80'
13+
line: 'server.port = 9091'
14+
15+
- name: Start Apache service
16+
become: yes
17+
service:
18+
name: lighttpd
19+
state: started
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[default]
2-
ec2-3-76-215-219.eu-central-1.compute.amazonaws.com ansible_ssh_private_key_file=/Users/rahulwagh/.ssh/aws_ec2_terraform
2+
ec2-3-69-241-84.eu-central-1.compute.amazonaws.com ansible_ssh_private_key_file=/Users/rahulwagh/.ssh/aws_ec2_terraform

0 commit comments

Comments
 (0)