First commit
parent
950d9b98b8
commit
b9b59122d3
@ -0,0 +1,19 @@
|
||||
ghost:
|
||||
- name: dryusdan.space
|
||||
account: dryusdan_space
|
||||
home: /opt/dryusdan_space
|
||||
url: dryusdan.space
|
||||
ghost_host: 127.0.0.1
|
||||
ghost_port: 7777
|
||||
db_host: 127.0.0.1
|
||||
db_port: 3306
|
||||
db_user: dryusdanspace
|
||||
db_password: Password
|
||||
db: dryusdanspace
|
||||
email_send: True
|
||||
email_from: contact@dryusdan.fr
|
||||
email_host: 127.0.0.1
|
||||
email_port: 587
|
||||
email_user: contact@dryusdan.fr
|
||||
email_pass: Password
|
||||
|
@ -0,0 +1,185 @@
|
||||
---
|
||||
- name: "Add ghost user"
|
||||
user:
|
||||
name: "{{ item.account }}"
|
||||
shell: "/bin/false"
|
||||
home: "{{ item.home }}"
|
||||
loop: "{{ ghost }}"
|
||||
when: ghost_deploy_site in item.name
|
||||
|
||||
- name: "Add www directory"
|
||||
file:
|
||||
path: "{{ item.home }}/www"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: "{{ item.account }}"
|
||||
group: "{{ item.account }}"
|
||||
loop: "{{ ghost }}"
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Add blog log directory"
|
||||
file:
|
||||
path: "/var/log/ghost/"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: "Add blog log directory"
|
||||
file:
|
||||
path: "/var/log/ghost/{{ item.name }}/"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: "{{ item.account }}"
|
||||
group: "{{ item.account }}"
|
||||
loop: "{{ ghost }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Download Ghost"
|
||||
get_url:
|
||||
url: "https://github.com/TryGhost/Ghost/releases/download/{{ version }}/Ghost-{{ version }}.zip"
|
||||
dest: "{{ item.home }}/ghost-latest.zip"
|
||||
mode: 0440
|
||||
loop: "{{ ghost }}"
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Delete www"
|
||||
file:
|
||||
path: "{{ item.home }}/www"
|
||||
state: absent
|
||||
loop: "{{ ghost }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Unzip Ghost"
|
||||
shell: "unzip -o ghost-latest.zip -d www"
|
||||
args:
|
||||
chdir: "{{ item.home }}/"
|
||||
loop: "{{ ghost }}"
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Unzip content folder Ghost"
|
||||
shell: "unzip -o ghost-latest.zip 'content/*' -d ./"
|
||||
args:
|
||||
chdir: "{{ item.home }}/"
|
||||
with_dict: "{{ ghost }}"
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Delete content"
|
||||
file:
|
||||
path: "{{ item.home }}/www/content"
|
||||
state: absent
|
||||
loop: "{{ ghost }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Symlink content"
|
||||
file:
|
||||
src: "{{ item.home }}/content"
|
||||
dest: "{{ item.home }}/www/content"
|
||||
state: link
|
||||
owner: "{{ item.account }}"
|
||||
group: "{{ item.account }}"
|
||||
loop: "{{ ghost }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
|
||||
- name: "Config ghost"
|
||||
template:
|
||||
src: "config.production.json.j2"
|
||||
dest: "{{ item.home }}/www/config.production.json"
|
||||
owner: "{{ item.account }}"
|
||||
group: "{{ item.account }}"
|
||||
loop: "{{ ghost }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Config daemon"
|
||||
template:
|
||||
src: "systemd.service.j2"
|
||||
dest: "/etc/systemd/system/{{ item.name }}.service"
|
||||
loop: "{{ ghost }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Install node modules"
|
||||
shell: "NODE_ENV=production npm i"
|
||||
args:
|
||||
chdir: "{{ item.home }}/www"
|
||||
loop: "{{ ghost }}"
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Install yarn module"
|
||||
shell: "NODE_ENV=production yarn install"
|
||||
args:
|
||||
chdir: "{{ item.home }}/www"
|
||||
loop: "{{ ghost }}"
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Knex init"
|
||||
shell: "NODE_ENV=production node_modules/knex-migrator/bin/knex-migrator init"
|
||||
args:
|
||||
chdir: "{{ item.home }}/www"
|
||||
loop: "{{ ghost }}"
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Knex migrate"
|
||||
shell: "NODE_ENV=production node_modules/knex-migrator/bin/knex-migrator migrate"
|
||||
args:
|
||||
chdir: "{{ item.home }}/www"
|
||||
loop: "{{ ghost }}"
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Reload systemctl"
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
|
||||
- name: "Enable service"
|
||||
systemd:
|
||||
name: "{{ item.name }}.service"
|
||||
enabled: yes
|
||||
loop: "{{ ghost }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Restart service"
|
||||
systemd:
|
||||
name: "{{ item.name }}.service"
|
||||
state: restarted
|
||||
loop: "{{ ghost }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Delete archive"
|
||||
file:
|
||||
path: "{{ item.home }}/ghost-latest.zip"
|
||||
state: absent
|
||||
loop: "{{ ghost }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "Clean cache yarn"
|
||||
shell: "yarn cache clean"
|
||||
args:
|
||||
chdir: "{{ item.home }}/"
|
||||
loop: "{{ ghost }}"
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
when: ghost_deploy_site in item.key
|
||||
|
||||
- name: "NPM Cache clean"
|
||||
shell: "npm cache clean --force"
|
||||
args:
|
||||
chdir: "{{ item.home }}/"
|
||||
loop: "{{ ghost }}"
|
||||
become: yes
|
||||
become_user : "{{ item.account }}"
|
||||
when: ghost_deploy_site in item.key
|
Binary file not shown.
@ -0,0 +1,57 @@
|
||||
{
|
||||
{% if item.url is defined %}
|
||||
"url": "https://{{ item.url }}",
|
||||
{% else %}
|
||||
"url": "https://{{ item.name }}",
|
||||
{% endif %}
|
||||
"server": {
|
||||
"port": {{ item.ghost_port }},
|
||||
"host": "{{ item.ghost_host }}"
|
||||
},
|
||||
"database": {
|
||||
"client": "mysql",
|
||||
"connection": {
|
||||
"host": "{{ item.db_host }}",
|
||||
"user": "{{ item.db_user }}",
|
||||
"password": "{{ item.db_password }}",
|
||||
"database": "{{ item.db }}"
|
||||
}
|
||||
},
|
||||
"privacy": {
|
||||
"useTinfoil": true
|
||||
},
|
||||
"mail": {
|
||||
{% if item.email_send == True %}
|
||||
"transport": "SMTP",
|
||||
"from": "{{ item.email_from }}",
|
||||
"options": {
|
||||
"host": "{{ item.email_host }}",
|
||||
"port": {{ item.email_port }},
|
||||
"auth": {
|
||||
"user": "{{ item.email_user }}",
|
||||
"pass": "{{ item.email_pass }}"
|
||||
}
|
||||
}
|
||||
{% else %}
|
||||
"transport": "Direct"
|
||||
{% endif %}
|
||||
},
|
||||
"logging": {
|
||||
"path": "/var/log/ghost/{{ item.name }}/",
|
||||
"level": "error",
|
||||
"rotation": {
|
||||
"enabled": true,
|
||||
"count": 15,
|
||||
"period": "1d"
|
||||
},
|
||||
"transports": [
|
||||
"file"
|
||||
]
|
||||
},
|
||||
"compress": true,
|
||||
"process": "systemd",
|
||||
"paths": {
|
||||
"contentPath": "{{ item.home }}/www/content"
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=Ghost blog for {{ item.name }}
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ item.account }}
|
||||
WorkingDirectory={{ item.home }}/www/
|
||||
Environment="NODE_ENV=production"
|
||||
ExecStart=/usr/bin/node index.js
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
Reference in New Issue