Updating chapter 8
authorLorin Hochstein <lhochstein@netflix.com>
Mon, 9 Jan 2017 00:31:38 +0000 (16:31 -0800)
committerLorin Hochstein <lhochstein@netflix.com>
Mon, 9 Jan 2017 00:31:38 +0000 (16:31 -0800)
ch08/playbooks/roles/database/handlers/main.yml
ch08/playbooks/roles/database/tasks/main.yml
ch08/playbooks/roles/mezzanine/handlers/main.yml
ch08/playbooks/roles/mezzanine/tasks/django.yml
ch08/playbooks/roles/mezzanine/tasks/main.yml
ch08/playbooks/roles/mezzanine/tasks/nginx.yml
ch08/playbooks/roles/mezzanine/templates/gunicorn.conf.py.j2
ch08/playbooks/roles/mezzanine/vars/main.yml

index b835c90..4b53914 100644 (file)
@@ -1,4 +1,4 @@
 ---
 - name: restart postgres
   service: name=postgresql state=restarted
-  sudo: True
+  become: True
index d8a2e16..9170395 100644 (file)
@@ -1,7 +1,7 @@
 ---
 - name: install apt packages
   apt: pkg={{ item }} update_cache=yes cache_valid_time=3600
-  sudo: True
+  become: True
   with_items:
     - libpq-dev
     - postgresql
   copy: >
     src=postgresql.conf dest=/etc/postgresql/9.3/main/postgresql.conf
     owner=postgres group=postgres mode=0644
-  sudo: True
+  become: True
   notify: restart postgres
 - name: copy client authentication configuration file
   copy: >
     src=pg_hba.conf dest=/etc/postgresql/9.3/main/pg_hba.conf
     owner=postgres group=postgres mode=0640
-  sudo: True
+  become: True
   notify: restart postgres
+- name: create project locale
+  locale_gen: name={{ locale }}
+  become: True
 - name: create a user
   postgresql_user:
     name: "{{ database_user }}"
     password: "{{ db_pass }}"
-  sudo: True
-  sudo_user: postgres
+  become: True
+  become_user: postgres
 - name: create the database
   postgresql_db:
     name: "{{ database_name }}"
@@ -32,5 +35,5 @@
     lc_ctype: "{{ locale }}"
     lc_collate: "{{ locale }}"
     template: template0
-  sudo: True
-  sudo_user: postgres
+  become: True
+  become_user: postgres
index 59e71cb..0913020 100644 (file)
@@ -1,7 +1,7 @@
 ---
 - name: restart supervisor
   supervisorctl: name=gunicorn_mezzanine state=restarted
-  sudo: True
+  become: True
 - name: restart nginx
   service: name=nginx state=restarted
-  sudo: True
+  become: True
index bb17ba1..19d453d 100644 (file)
   template: src=gunicorn.conf.py.j2 dest={{ mezzanine_proj_path }}/gunicorn.conf.py
 - name: set the supervisor config file
   template: src=supervisor.conf.j2 dest=/etc/supervisor/conf.d/mezzanine.conf
-  sudo: True
+  become: True
   notify: restart supervisor
 - name: ensure config path exists
   file: path={{ mezzanine_conf_path }} state=directory
-  sudo: True
+  become: True
   when: tls_enabled
 - name: install poll twitter cron job
   cron: >
index 7ac8e3a..975a15e 100644 (file)
@@ -1,7 +1,7 @@
 ---
 - name: install apt packages
   apt: pkg={{ item }} update_cache=yes cache_valid_time=3600
-  sudo: True
+  become: True
   with_items:
     - git
     - libjpeg-dev
index 41482e8..1852181 100644 (file)
@@ -1,24 +1,24 @@
 - name: set the nginx config file
   template: src=nginx.conf.j2 dest=/etc/nginx/sites-available/mezzanine.conf
   notify: restart nginx
-  sudo: True
+  become: True
 - name: enable the nginx config file
   file:
     src: /etc/nginx/sites-available/mezzanine.conf
     dest: /etc/nginx/sites-enabled/mezzanine.conf
     state: link
   notify: restart nginx
-  sudo: True
+  become: True
 - name: remove the default nginx config file
   file: path=/etc/nginx/sites-enabled/default state=absent
   notify: restart nginx
-  sudo: True
+  become: True
 - name: create ssl certificates
   command: >
     openssl req -new -x509 -nodes -out {{ mezzanine_proj_name }}.crt
     -keyout {{ mezzanine_proj_name }}.key -subj '/CN={{ domains[0] }}' -days 3650
     chdir={{ mezzanine_conf_path }}
     creates={{ mezzanine_conf_path }}/{{ mezzanine_proj_name }}.crt
-  sudo: True
+  become: True
   when: tls_enabled
   notify: restart nginx
index 77f9872..c12307c 100644 (file)
@@ -1,7 +1,8 @@
 from __future__ import unicode_literals
 import multiprocessing
 
-bind = "127.0.0.1:{{ mezzanine_gunicorn_port }}"
-workers = multiprocessing.cpu_count() * 2 + 1
+bind = "unix:{{ mezzanine_proj_path }}/gunicorn.sock"
+workers = {{ mezzanine_num_workers }}
+errorlog = "/home/{{ mezzanine_user }}/logs/{{ mezzanine_proj_name }}_error.log"
 loglevel = "error"
 proc_name = "{{ mezzanine_proj_name }}"
index 40d1c79..657d868 100644 (file)
@@ -1,13 +1,12 @@
 ---
 # vars file for mezzanine
 mezzanine_user: "{{ ansible_user }}"
-mezzanine_venv_home: "{{ ansible_env.HOME }}"
-mezzanine_venv_path: "{{ mezzanine_venv_home }}/{{ mezzanine_proj_name }}"
-mezzanine_repo_url: git@github.com:lorin/mezzanine-example.git
-mezzanine_proj_dirname: project
-mezzanine_proj_path: "{{ mezzanine_venv_path }}/{{ mezzanine_proj_dirname }}"
+mezzanine_venv_home: "{{ ansible_env.HOME }}/.virtualenvs"
+mezzanine_venv_path: "{{ venv_home }}/{{ proj_name }}"
+mezzanine_repo_url: git@github.com:ansiblebook/mezzanine_example.git
+mezzanine_proj_path: "{{ ansible_env.HOME }}/mezzanine/{{ mwzzanine_proj_name }}"
 mezzanine_reqs_path: requirements.txt
 mezzanine_conf_path: /etc/nginx/conf
 mezzanine_python: "{{ mezzanine_venv_path }}/bin/python"
 mezzanine_manage: "{{ mezzanine_python }} {{ mezzanine_proj_path }}/manage.py"
-mezzanine_gunicorn_port: 8000
+mezzanine_num_workers: "multiprocessing.cpu_count() * 2 + 1"