ansible
This commit is contained in:
parent
fbe4ca031f
commit
9d36de968f
1
.python-version
Normal file
1
.python-version
Normal file
@ -0,0 +1 @@
|
|||||||
|
ansible-3.11.0
|
3
ansible.cfg
Normal file
3
ansible.cfg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[defaults]
|
||||||
|
inventory = inventory
|
||||||
|
private_key_file = ~/.ssh/ansible
|
3
files/index.html
Normal file
3
files/index.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<h1>Amazing website!</h1>
|
||||||
|
|
||||||
|
<h4>Testing ansible</h1>
|
14
files/my-site.nginx.conf
Normal file
14
files/my-site.nginx.conf
Normal 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
58
install_nginx.yml
Normal 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
|
9
remove_nginx.yml
Normal file
9
remove_nginx.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
- hosts: all
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: install nginx package
|
||||||
|
apt:
|
||||||
|
name: nginx
|
||||||
|
state: latest
|
||||||
|
|
Loading…
Reference in New Issue
Block a user