Browse Source

[WIP] Services

services
Slash 8 years ago
parent
commit
14e978d54b
12 changed files with 60 additions and 30 deletions
  1. +5
    -0
      handlers/service.yaml
  2. +8
    -0
      roles/apache/tasks/main.yaml
  3. +8
    -0
      roles/mysql/tasks/main.yaml
  4. +8
    -4
      roles/nginx/handlers/main.yaml
  5. +16
    -7
      roles/nginx/tasks/main.yaml
  6. +0
    -0
      roles/nginx/templates/site_config.j2
  7. +0
    -3
      roles/nginx_proxy/meta/main.yaml
  8. +0
    -15
      roles/nginx_proxy/tasks/main.yaml
  9. +3
    -0
      roles/wordpress/meta/main.yaml
  10. +5
    -0
      roles/wordpress/tasks/main.yaml
  11. +6
    -0
      tasks/service.yaml
  12. +1
    -1
      team_server.yaml

+ 5
- 0
handlers/service.yaml View File

@ -0,0 +1,5 @@
---
- name: restart {{ service_name }}
service: name={{ service_name }} state=restarted
- name: reload {{ service_name }}
service: name={{ service_name }} state=reloaded

+ 8
- 0
roles/apache/tasks/main.yaml View File

@ -0,0 +1,8 @@
---
- name: install apache
apt: name={{ item }} state=latest
with_items:
- apache2
- name: start apache at boot
service: name=apache2 state=started enabled=yes

+ 8
- 0
roles/mysql/tasks/main.yaml View File

@ -0,0 +1,8 @@
---
- name: install mysql
apt: name={{ item }} state=latest
with_items:
- mysql
- name: start mysql at boot
service: name=mysql state=started enabled=yes

+ 8
- 4
roles/nginx/handlers/main.yaml View File

@ -1,10 +1,14 @@
--- ---
- name: restart nginx
service: name=nginx state=restarted
- include: service.yaml
service_name: nginx
- name: validate nginx configuration - name: validate nginx configuration
command: nginx -t -c /etc/nginx/nginx.conf command: nginx -t -c /etc/nginx/nginx.conf
changed_when: False changed_when: False
- name: reload nginx
service: name=nginx state=reloaded
- name: enable nginx configuration
file:
src: "/etc/nginx/sites-available/{{ config_name }}"
dest: "/etc/nginx/sites-enabled/{{ config_name }}"
state: link
notify: restart nginx

+ 16
- 7
roles/nginx/tasks/main.yaml View File

@ -1,8 +1,17 @@
--- ---
- name: install nginx
apt: pkg=nginx state=latest
- name: start nginx at boot
service: name=nginx state=started enabled=yes
# - name: copy nginx configuration
# template: src={{ configuration_file }} dest=/etc/nginx/sites-available/{{ dest }}
# notify: restart nginx
- include: service.yaml
service_name: nginx
service_packages:
- nginx
- name: disable nginx default configuration
file: path=/etc/nginx/sites-enabled/default state=absent
notify: restart nginx
- name: upload nginx proxy configuration
template:
src: proxy_config.j2
dest: "/etc/nginx/sites-available/{{ config_name }}"
tags:
- proxy
notify:
- enable nginx configuration
- restart nginx

roles/nginx_proxy/templates/site_config.j2 → roles/nginx/templates/site_config.j2 View File


+ 0
- 3
roles/nginx_proxy/meta/main.yaml View File

@ -1,3 +0,0 @@
---
dependencies:
- nginx

+ 0
- 15
roles/nginx_proxy/tasks/main.yaml View File

@ -1,15 +0,0 @@
---
- name: upload nginx proxy configuration
template:
src: site_config.j2
dest: "/etc/nginx/sites-available/{{ config_name }}"
notify: restart nginx
- name: disable nginx default configuration
file: path=/etc/nginx/sites-enabled/default state=absent
notify: restart nginx
- name: enable nginx proxy configuration
file:
src: "/etc/nginx/sites-available/{{ config_name }}"
dest: "/etc/nginx/sites-enabled/{{ config_name }}"
state: link
notify: restart nginx

+ 3
- 0
roles/wordpress/meta/main.yaml View File

@ -0,0 +1,3 @@
---
dependencies:
- role: apache

+ 5
- 0
roles/wordpress/tasks/main.yaml View File

@ -0,0 +1,5 @@
---
- name: install wordpress
apt: name={{ item }} state=latest
with_items:
- wordpress

+ 6
- 0
tasks/service.yaml View File

@ -0,0 +1,6 @@
---
- name: install {{ service_name }}
apt: name={{ item }} state=present
with_items: {{ service_packages }}
- name: start {{ service_name }} at boot
service: name={{ service_name }} state=started enabled=yes

+ 1
- 1
team_server.yaml View File

@ -6,7 +6,7 @@
- hosts: team - hosts: team
roles: roles:
- role: mattermost - role: mattermost
- role: nginx_proxy
- role: nginx
server_name: "team.lilik.it" server_name: "team.lilik.it"
config_name: "mattermost" config_name: "mattermost"
remote_host: "http://127.0.0.1:8065" remote_host: "http://127.0.0.1:8065"

Loading…
Cancel
Save