-
-
Save jvns/06754e9e65b49dd461fefa071dd4aace to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - hosts: staticsites | |
| become: yes | |
| tasks: | |
| - name: Install nginx | |
| apt: name=nginx state=present | |
| - name: Make sure nginx is started now and at boot. | |
| service: name=nginx state=started enabled=yes | |
| - name: Remove default nginx site | |
| file: path=/etc/nginx/sites-enabled/default state=absent | |
| - name: Copy nginx sites | |
| template: | |
| src: sites/domain.conf | |
| dest: "/etc/nginx/sites-enabled/{{item.dir}}.conf" | |
| owner: root | |
| group: root | |
| mode: 0644 | |
| loop: | |
| - server: wizardzines.com www.wizardzines.com | |
| dir: wizardzines.com | |
| - server: jvns.ca www.jvns.ca | |
| dir: jvns.ca | |
| - server: questions.wizardzines.com | |
| dir: questions.wizardzines.com | |
| - server: mysteries.wizardzines.com | |
| dir: mysteries.wizardzines.com | |
| - server: feedback.wizardzines.com | |
| dir: feedback.wizardzines.com | |
| - server: css-examples.wizardzines.com | |
| dir: css-examples.wizardzines.com | |
| - server: sql-steps.wizardzines.com | |
| dir: sql-steps.wizardzines.com | |
| - server: flashcards.wizardzines.com | |
| dir: flashcards.wizardzines.com | |
| - server: sql-playground.wizardzines.com | |
| dir: sql-playground.wizardzines.com | |
| - server: drawings.jvns.ca | |
| dir: drawings.jvns.ca | |
| notify: reload nginx | |
| - name: Create /var/www directories | |
| file: | |
| path: "/var/www/{{item}}" | |
| state: directory | |
| loop: | |
| - questions.wizardzines.com | |
| - mysteries.wizardzines.com | |
| - feedback.wizardzines.com | |
| - sql-playground.wizardzines.com | |
| - sql-steps.wizardzines.com | |
| - flashcards.wizardzines.com | |
| - css-examples.wizardzines.com | |
| - jvns.ca | |
| - drawings.jvns.ca | |
| - wizardzines.com | |
| - name: Copy custom nginx files | |
| copy: | |
| src: "{{item.src}}" | |
| dest: "{{item.dest}}" | |
| owner: root | |
| group: root | |
| mode: 0644 | |
| loop: | |
| - src: nginx.conf | |
| dest: /etc/nginx/nginx.conf | |
| - src: sites/default.conf | |
| dest: /etc/nginx/sites-enabled/default.conf | |
| - src: sites/wizardzines.com.conf | |
| dest: /etc/nginx/sites-enabled/wizardzines.com.conf | |
| notify: reload nginx | |
| - name: Copy logrotate config | |
| copy: | |
| src: logrotate | |
| dest: /etc/logrotate.d/nginx | |
| owner: root | |
| group: root | |
| mode: 0644 | |
| # Systemd stuff | |
| - name: PPP | Create user | |
| user: | |
| name: ppp | |
| shell: /usr/bin/nologin | |
| uid: 1000 | |
| - name: PPP | Create Unit file | |
| template: | |
| src: ppp.service | |
| dest: /lib/systemd/system/ppp.service | |
| mode: 0644 | |
| notify: | |
| - reload systemctl | |
| - name: PPP | Start service | |
| service: name=ppp.service state=started enabled=yes | |
| handlers: | |
| - name: reload nginx | |
| debug: msg="checking config first" | |
| changed_when: True | |
| notify: | |
| - check nginx configuration | |
| - reload nginx - after config check | |
| - name: check nginx configuration | |
| command: "nginx -t" | |
| register: result | |
| changed_when: "result.rc != 0" | |
| - name: reload nginx - after config check | |
| service: name=nginx state=reloaded | |
| - name: reload systemctl | |
| command: systemctl daemon-reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment