Advertisement
PandaAcademy

Nginx playbook - 1

Mar 12th, 2024
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.66 KB | None | 0 0
  1. ---
  2. - name: Install Nginx
  3.   hosts: all
  4.   connection: local
  5.   become: yes
  6.   tasks:
  7.     - name: Update apt package index
  8.       apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
  9.  
  10.     - name: Install Nginx
  11.       apt:
  12.         name: nginx
  13.         state: present
  14.  
  15.     - name: Ensure Nginx is running and enabled
  16.       systemd:
  17.         name: nginx
  18.         state: started
  19.         enabled: yes
  20.  
  21.     - name: Copy Nginx server block file
  22.       copy:
  23.         src: "templates/site.conf"
  24.         dest: "/etc/nginx/sites-enabled/site.conf"
  25.  
  26.     - name: Reload Nginx if configuration changed
  27.       systemd:
  28.         name: nginx
  29.         state: reloaded
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement