Download:
child 19:0b0d1d97f49f
parent 17:5a3522b5fd5c
18:464f9dec4e2f
Anton Shestakov <av6@dwimlabs.net>, Mon, 27 Jun 2016 16:49:16 +0800
use a more YAMLy syntax everywhere Some lines were getting out of hand length-wise.

4 файлов изменено, 68 вставок(+), 21 удалений(-) [+]
playbook-example.yml file | annotate | diff | comparison | revisions
roles/hgweb/handlers/main.yml file | annotate | diff | comparison | revisions
roles/hgweb/tasks/appinstall.yml file | annotate | diff | comparison | revisions
roles/hgweb/tasks/main.yml file | annotate | diff | comparison | revisions
--- a/playbook-example.yml Mon Jun 27 16:30:20 2016 +0800
+++ b/playbook-example.yml Mon Jun 27 16:49:16 2016 +0800
@@ -9,9 +9,12 @@
# need to use the virtual host name (i.e. http://127.0.0.1/ won't work).
# Make sure you have DNS records for hg.mydomain or add it to /etc/hosts.
- name: Set hostname
- hostname: name={{ hostname }}
+ hostname:
+ name: '{{ hostname }}'
- name: Update /etc/hosts
- lineinfile: dest=/etc/hosts line="127.0.0.1 {{ hostname }} hg.{{ hostname }}"
+ lineinfile:
+ dest: /etc/hosts
+ line: '127.0.0.1 {{ hostname }} hg.{{ hostname }}'
# NOTE: this role depends on nginx and supervisor packages being installed,
# and also it uses two handlers:
@@ -20,11 +23,19 @@
# This role doesn't have the handlers, so this playbook restarts the
# services in post_tasks instead.
- name: Install Nginx
- apt: package=nginx-full state=installed update_cache=yes cache_valid_time=3600
+ apt:
+ update_cache: yes
+ cache_valid_time: 3600
+ package: nginx-full
+ state: installed
- name: Disable default Nginx site
- file: path=/etc/nginx/sites-enabled/default state=absent
+ file:
+ path: /etc/nginx/sites-enabled/default
+ state: absent
- name: Install Supervisor
- apt: package=supervisor state=installed
+ apt:
+ package: supervisor
+ state: installed
roles:
# - role: nginx
# tags: [nginx]
@@ -34,7 +45,12 @@
tags: [hgweb]
post_tasks:
- name: Restart Nginx
- service: name=nginx state=restarted
+ service:
+ name: nginx
+ state: restarted
- name: Restart Supervisor
- service: name=supervisor state=restarted sleep=1
+ service:
+ name: supervisor
+ state: restarted
+ sleep: 1
...
--- a/roles/hgweb/handlers/main.yml Mon Jun 27 16:30:20 2016 +0800
+++ b/roles/hgweb/handlers/main.yml Mon Jun 27 16:49:16 2016 +0800
@@ -5,5 +5,7 @@
become_user: '{{ hgweb_user }}'
- name: restart hgweb
- supervisorctl: name=hgweb state=restarted
+ supervisorctl:
+ name: hgweb
+ state: restarted
...
--- a/roles/hgweb/tasks/appinstall.yml Mon Jun 27 16:30:20 2016 +0800
+++ b/roles/hgweb/tasks/appinstall.yml Mon Jun 27 16:49:16 2016 +0800
@@ -1,28 +1,40 @@
---
- name: Ensure required directories exist
- file: path=/home/{{ hgweb_user }}/{{ item }}/ state=directory
+ file:
+ path: /home/{{ hgweb_user }}/{{ item }}/
+ state: directory
with_items:
- hgwebfiles
- repos
- name: Add .hgrc
- copy: src=.hgrc dest=/home/{{ hgweb_user }}/.hgrc
+ copy:
+ src: .hgrc
+ dest: /home/{{ hgweb_user }}/.hgrc
- name: Pull Mercurial {{ hgweb_mercurial_rev }}
- hg: repo={{ hgweb_mercurial_url }} dest=/home/{{ hgweb_user }}/hg/ revision={{ hgweb_mercurial_rev }}
+ hg:
+ repo: '{{ hgweb_mercurial_url }}'
+ dest: /home/{{ hgweb_user }}/hg/
+ revision: '{{ hgweb_mercurial_rev }}'
notify:
- make local
- restart hgweb
tags: [inert]
- name: Pull Evolve {{ hgweb_evolve_rev }}
- hg: repo={{ hgweb_evolve_url }} dest=/home/{{ hgweb_user }}/evolve/ revision={{ hgweb_evolve_rev }}
+ hg:
+ repo: '{{ hgweb_evolve_url }}'
+ dest: /home/{{ hgweb_user }}/evolve/
+ revision: '{{ hgweb_evolve_rev }}'
notify:
- restart hgweb
tags: [inert]
- name: Add config files
- template: src={{ item }} dest=/home/{{ hgweb_user }}/hgwebfiles/{{ item }}
+ template:
+ src: '{{ item }}'
+ dest: /home/{{ hgweb_user }}/hgwebfiles/{{ item }}
with_items:
- hgweb.py
- hgweb.conf
@@ -31,10 +43,15 @@
- restart hgweb
- name: Copy requirements.txt
- copy: src=requirements.txt dest=/home/{{ hgweb_user }}/hgwebfiles/requirements.txt
+ copy:
+ src: requirements.txt
+ dest: /home/{{ hgweb_user }}/hgwebfiles/requirements.txt
- name: Set up venv for gunicorn
- pip: requirements=/home/{{ hgweb_user }}/hgwebfiles/requirements.txt state=latest virtualenv=/home/{{ hgweb_user }}/hgwebfiles/venv/
+ pip:
+ virtualenv: /home/{{ hgweb_user }}/hgwebfiles/venv/
+ requirements: /home/{{ hgweb_user }}/hgwebfiles/requirements.txt
+ state: latest
notify:
- restart hgweb
...
--- a/roles/hgweb/tasks/main.yml Mon Jun 27 16:30:20 2016 +0800
+++ b/roles/hgweb/tasks/main.yml Mon Jun 27 16:49:16 2016 +0800
@@ -1,9 +1,12 @@
---
- name: Create user
- user: name={{ hgweb_user }}
+ user:
+ name: '{{ hgweb_user }}'
- name: Install packages
- apt: pkg={{ item }} state=present
+ apt:
+ pkg: '{{ item }}'
+ state: present
with_items:
- build-essential
- mercurial
@@ -12,7 +15,9 @@
tags: [packages, inert]
- name: Install virtualenv
- apt: pkg=virtualenv state=present
+ apt:
+ pkg: virtualenv
+ state: present
when: ansible_distribution_release == 'jessie'
tags: [packages, inert]
@@ -21,17 +26,24 @@
become_user: '{{ hgweb_user }}'
- name: Add supervisor app
- template: src=etc/supervisor/conf.d/hgweb.conf dest=/etc/supervisor/conf.d/hgweb.conf
+ template:
+ src: etc/supervisor/conf.d/hgweb.conf
+ dest: /etc/supervisor/conf.d/hgweb.conf
notify:
- reload supervisor
- name: Add {{ hgweb_subdomain }}.{{ hostname }} Nginx site
- template: src=etc/nginx/sites-available/hgweb dest=/etc/nginx/sites-available/{{ hgweb_subdomain }}.{{ hostname }}
+ template:
+ src: etc/nginx/sites-available/hgweb
+ dest: /etc/nginx/sites-available/{{ hgweb_subdomain }}.{{ hostname }}
notify:
- restart nginx
- name: Enable {{ hgweb_subdomain }}.{{ hostname }} Nginx site
- file: src=/etc/nginx/sites-available/{{ hgweb_subdomain }}.{{ hostname }} dest=/etc/nginx/sites-enabled/50{{ hgweb_subdomain }}.{{ hostname }} state=link
+ file:
+ src: /etc/nginx/sites-available/{{ hgweb_subdomain }}.{{ hostname }}
+ dest: /etc/nginx/sites-enabled/50{{ hgweb_subdomain }}.{{ hostname }}
+ state: link
notify:
- restart nginx
...