Put it in a block

This commit is contained in:
Julien Palard 2019-12-16 23:07:18 +01:00
parent cfef88b78f
commit 84c30c482b
4 changed files with 77 additions and 81 deletions

View File

@ -1,4 +1,52 @@
---
- include: pelican.yml
tags: pelican
- block:
- name: Install nginx and dependencies
apt:
name: [nginx, git]
- name: Create user
user:
name: "{{ pelican_user }}"
shell: /bin/false
system: yes
home: "{{ pelican_home }}"
- name: Clone repo
git:
repo: "{{ pelican_repo }}"
dest: "{{ pelican_home }}/repo"
register: clone_repo
- name: pip install pelican markdown
pip:
name: [pelican, markdown]
virtualenv_command: /usr/bin/python3 -m venv
virtualenv: "{{ pelican_home }}/venv"
- name: Ensure pelican can write in its output dir
file:
path: "{{ pelican_home }}/www/"
state: directory
owner: "{{ pelican_user }}"
mode: 0755
- name: Build pelican
when: clone_repo.changed
command: "{{ pelican_home }}/venv/bin/pelican -o {{ pelican_home }}/www/"
args:
chdir: "{{ pelican_home }}/repo/{{ pelican_path_in_repo }}"
become: true
become_method: su
become_user: "{{ pelican_user }}"
become_flags: "-s /bin/sh"
- name: Configure nginx
template:
src: nginx-vhost
dest: "/etc/nginx/conf.d/{{ pelican_domain }}.conf"
owner: root
group: root
mode: 0644
notify: reload nginx
tags: [pelican]

View File

@ -1,50 +0,0 @@
---
- name: Install nginx and dependencies
apt:
name: [nginx, git]
- name: Create user
user:
name: "{{ pelican_user }}"
shell: /bin/false
system: yes
home: "{{ pelican_home }}"
- name: Clone repo
git:
repo: "{{ pelican_repo }}"
dest: "{{ pelican_home }}/repo"
register: clone_repo
- name: pip install pelican markdown
pip:
name: [pelican, markdown]
virtualenv_command: /usr/bin/python3 -m venv
virtualenv: "{{ pelican_home }}/venv"
- name: Ensure pelican can write in its output dir
file:
path: "{{ pelican_home }}/www/"
state: directory
owner: "{{ pelican_user }}"
mode: 0755
- name: Build pelican
when: clone_repo.changed
command: "{{ pelican_home }}/venv/bin/pelican -o {{ pelican_home }}/www/"
args:
chdir: "{{ pelican_home }}/repo/{{ pelican_path_in_repo }}"
become: true
become_method: su
become_user: "{{ pelican_user }}"
become_flags: "-s /bin/sh"
- name: Configure nginx
template:
src: nginx-vhost
dest: "/etc/nginx/conf.d/{{ pelican_domain }}.conf"
owner: root
group: root
mode: 0644
notify: reload nginx

View File

@ -1,4 +1,29 @@
---
- include: static.yml
tags: static
- block:
- name: Install nginx and dependencies
apt:
name: [nginx, git]
- name: Create user
user:
name: "{{ static_user }}"
shell: /bin/false
system: yes
home: "{{ static_home }}"
- name: Clone repo
git:
repo: "{{ static_repo }}"
dest: "{{ static_home }}/www/"
register: clone_repo
- name: Configure nginx
template:
src: nginx-vhost
dest: "/etc/nginx/conf.d/{{ static_domain }}.conf"
owner: root
group: root
mode: 0644
notify: reload nginx
tags: [static]

View File

@ -1,27 +0,0 @@
---
- name: Install nginx and dependencies
apt:
name: [nginx, git]
- name: Create user
user:
name: "{{ static_user }}"
shell: /bin/false
system: yes
home: "{{ static_home }}"
- name: Clone repo
git:
repo: "{{ static_repo }}"
dest: "{{ static_home }}/www/"
register: clone_repo
- name: Configure nginx
template:
src: nginx-vhost
dest: "/etc/nginx/conf.d/{{ static_domain }}.conf"
owner: root
group: root
mode: 0644
notify: reload nginx