aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles')
-rw-r--r--ansible/roles/README.md2
-rw-r--r--ansible/roles/nginx/update_nginx.yml25
2 files changed, 26 insertions, 1 deletions
diff --git a/ansible/roles/README.md b/ansible/roles/README.md
index 1bef866..59841b5 100644
--- a/ansible/roles/README.md
+++ b/ansible/roles/README.md
@@ -3,4 +3,4 @@
This folder contains reusable Ansible roles for configuration management.
## Available Roles
--
+- nginx
diff --git a/ansible/roles/nginx/update_nginx.yml b/ansible/roles/nginx/update_nginx.yml
new file mode 100644
index 0000000..4813e6c
--- /dev/null
+++ b/ansible/roles/nginx/update_nginx.yml
@@ -0,0 +1,25 @@
+---
+- name: Update nginx if needed
+ hosts: vps
+ become: true
+ become_user: root
+ tasks:
+
+ - name: Ensure nginx is at the latest version
+ ansible.builtin.package:
+ name: nginx
+ state: latest
+ notify: restart nginx
+
+ - name: Ensure nginx is running
+ ansible.builtin.service:
+ name: nginx
+ state: started
+ enabled: true
+
+ handlers:
+ - name: Restart nginx
+ ansible.builtin.service:
+ name: nginx
+ state: restarted
+...