This commit is contained in:
Franco Colmenarez 2023-01-24 23:46:43 -05:00
parent fbe4ca031f
commit 9d36de968f
7 changed files with 89 additions and 0 deletions

1
.python-version Normal file
View File

@ -0,0 +1 @@
ansible-3.11.0

3
ansible.cfg Normal file
View File

@ -0,0 +1,3 @@
[defaults]
inventory = inventory
private_key_file = ~/.ssh/ansible

3
files/index.html Normal file
View File

@ -0,0 +1,3 @@
<h1>Amazing website!</h1>
<h4>Testing ansible</h1>

14
files/my-site.nginx.conf Normal file
View File

@ -0,0 +1,14 @@
server {
listen 80;
root /var/www/html/my-site;
index index.html index.htm;
server_name localhost;
location / {
default_type "text/html";
try_files $uri.html $uri $uri/ =404;
}
}

58
install_nginx.yml Normal file
View File

@ -0,0 +1,58 @@
- hosts: all
become: true
tasks:
- name: update repository index
apt:
update_cache: yes
state: latest
# when: ansible_distribution == "Ubuntu"
# when: ansible_distribution in ["Debian", "Ubuntu", "Pop"]
- name: install nginx package
apt:
name: nginx
state: latest
- name: delete default site
file:
path: /etc/nginx/sites-enabled/default
state: absent
- name: copy config file of site
copy:
src: files/my-site.nginx.conf
dest: /etc/nginx/sites-available/my-site
mode: preserve
- name: Folder for the site
file:
path: /var/www/html/my-site
state: directory
- name: copy actual site
copy:
src: files/index.html
dest: /var/www/html/my-site/index.html
mode: preserve
- name: enable site
file:
src: /etc/nginx/sites-available/my-site
dest: /etc/nginx/sites-enabled/my-site
state: link
- name: enable port 80
ufw:
rule: allow
port: 80
- name: reload nginx
service:
name: nginx
state: reloaded
handlers:
- name: restart nginx
service:
name: nginx
state: restarted

1
inventory Normal file
View File

@ -0,0 +1 @@
192.168.122.161

9
remove_nginx.yml Normal file
View File

@ -0,0 +1,9 @@
- hosts: all
become: true
tasks:
- name: install nginx package
apt:
name: nginx
state: latest