ghost setup ensure started
Some checks are pending
/ run ansible (push) Waiting to run

This commit is contained in:
Gabriel Augendre 2024-10-20 10:59:22 +02:00
parent f385090052
commit 96585b08f3
11 changed files with 100 additions and 85 deletions

View file

@ -18,7 +18,7 @@
with_fileglob: with_fileglob:
- templates/bin/*.j2 - templates/bin/*.j2
vars: vars:
ghost_db_password: !vault | ghost_setup_db_password: !vault |
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256
35343430343439653064613033383830396264306538376535346637613166376663393062353132 35343430343439653064613033383830396264306538376535346637613166376663393062353132
6537386534656239333731313938653539643165323532380a336162663839303339623266383662 6537386534656239333731313938653539643165323532380a336162663839303339623266383662

View file

@ -3,26 +3,20 @@
hosts: servers hosts: servers
gather_facts: false gather_facts: false
tasks: tasks:
- name: Write config files - name: Setup ghost gabnotes.org
ansible.builtin.template: ansible.builtin.include_role:
src: templates/ghost-config/{{ item.filename }} name: ghost_setup
dest: /mnt/data/{{ item.site }}/config.production.json vars:
mode: "0664" ghost_setup_filename: gabnotes-org-config.json.j2
notify: ghost_setup_site: gabnotes.org
- Restart service ghost_setup_db_password: !vault |
loop_control:
label: "{{ item.site }}"
loop:
- filename: gabnotes-org-config.json.j2
site: gabnotes.org
db_password: !vault |
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256
66306233626430393737653333313461666665363936376465623137656561356431373666363032 66306233626430393737653333313461666665363936376465623137656561356431373666363032
6537313234336331626464336434343462623264633463330a353165396163653666636333633537 6537313234336331626464336434343462623264633463330a353165396163653666636333633537
33353464393836623861633238663336336465326435613638613734613433386537663635666332 33353464393836623861633238663336336465326435613638613734613433386537663635666332
6338343039393737310a356335666632303062353336613364323165633239323032346239376262 6338343039393737310a356335666632303062353336613364323165633239323032346239376262
32323862393264326162383761653163353731363331326337633461643364373936 32323862393264326162383761653163353731363331326337633461643364373936
mail_password: !vault | ghost_setup_mail_password: !vault |
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256
61313164316335333431656136326636353535643363623665326565303961356234353362646261 61313164316335333431656136326636353535643363623665326565303961356234353362646261
3339616561643434376163613962366631303863313263310a323330316230333864636232386632 3339616561643434376163613962366631303863313263310a323330316230333864636232386632
@ -31,16 +25,20 @@
62346530353634383935303031343737326335326361313765393664613236356364313161373834 62346530353634383935303031343737326335326361313765393664613236356364313161373834
35396435303337643330393266376139616164613730643037303039633337343262303335616366 35396435303337643330393266376139616164613730643037303039633337343262303335616366
373032363533393263323835363666623966 373032363533393263323835363666623966
- filename: voyages-coccomagnard-fr-config.json.j2 - name: Setup ghost voyages.coccomagnard.fr
site: voyages.coccomagnard.fr ansible.builtin.include_role:
db_password: !vault | name: ghost_setup
vars:
ghost_setup_filename: voyages-coccomagnard-fr-config.json.j2
ghost_setup_site: voyages.coccomagnard.fr
ghost_setup_db_password: !vault |
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256
33623632396330303536366136313438623138366231333063613539303538303761386264623239 33623632396330303536366136313438623138366231333063613539303538303761386264623239
3266366633343936356564636131303939636330336335390a313430346536666239656562393238 3266366633343936356564636131303939636330336335390a313430346536666239656562393238
32373533373663656435306239643638313937623631366262393462306138323061333961363938 32373533373663656435306239643638313937623631366262393462306138323061333961363938
3239373062613138660a393933393436633166303837303263356232336666386336346366373934 3239373062613138660a393933393436633166303837303263356232336666386336346366373934
38346330616639646666616161613865643461643965333237353936663933336533 38346330616639646666616161613865643461643965333237353936663933336533
mail_password: !vault | ghost_setup_mail_password: !vault |
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256
33386530613164633962393133316231613664623761336237353335336430313637356430306430 33386530613164633962393133316231613664623761336237353335336430313637356430306430
3837373934336361636461343338643737653839396336340a633130613038666534653865303338 3837373934336361636461343338643737653839396336340a633130613038666534653865303338
@ -49,16 +47,20 @@
62653636613263303066333833623637653532663939656339376636356261666235656562336661 62653636613263303066333833623637653532663939656339376636356261666235656562336661
36376233386235393164363064373733623330306362343039623465303134313434366433383863 36376233386235393164363064373733623330306362343039623465303134313434366433383863
656136646536333065616631336235623430 656136646536333065616631336235623430
- filename: voyages-lois-augendre-info-config.json.j2 - name: Setup ghost voyages-lois.augendre.info
site: voyages-lois.augendre.info ansible.builtin.include_role:
db_password: !vault | name: ghost_setup
vars:
ghost_setup_filename: voyages-lois-augendre-info-config.json.j2
ghost_setup_site: voyages-lois.augendre.info
ghost_setup_db_password: !vault |
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256
30623130336131633738353931653239623133326265363862353530303232633333383462663330 30623130336131633738353931653239623133326265363862353530303232633333383462663330
3935333936383663326162653864623630396363666131390a393532336531663262616431396165 3935333936383663326162653864623630396363666131390a393532336531663262616431396165
33303236363739636665616636326262336532623234666263363563633962343734613565373031 33303236363739636665616636326262336532623234666263363563633962343734613565373031
3139313038663432370a623363366436643862343734393334306162376634366637616536303035 3139313038663432370a623363366436643862343734393334306162376634366637616536303035
32653739373732613930376336636332343333643436633261616561633034623566 32653739373732613930376336636332343333643436633261616561633034623566
mail_password: !vault | ghost_setup_mail_password: !vault |
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256
35353737376566653462393530613034353763643166626432613836663638636562303762343133 35353737376566653462393530613034353763643166626432613836663638636562303762343133
6132313762353565646531613336663336313765623430310a616438613433333632343933373330 6132313762353565646531613336663336313765623430310a616438613433333632343933373330
@ -66,15 +68,3 @@
3739313432356262330a626432386536663638646539323861356564616436386464366333303564 3739313432356262330a626432386536663638646539323861356564616436386464366333303564
35303230623365636362323733623531343335376361313430373936663836353132643834643664 35303230623365636362323733623531343335376361313430373936663836353132643834643664
6163326436323961636462616430366364626532323861656436 6163326436323961636462616430366364626532323861656436
register: config_files
handlers:
- name: Restart service
ansible.builtin.command:
cmd: ghost restart
chdir: /mnt/data/{{ item.item.site }}
when: item.changed
changed_when: true
loop: "{{ config_files.results }}"
loop_control:
label: "{{ item.item.site }}"

View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
/usr/bin/mysqldump --no-tablespaces -u root --password={{ ghost_db_password }} gabnotes_org_prod > /mnt/data/gabnotes.org/db_export/backup.sql /usr/bin/mysqldump --no-tablespaces -u root --password={{ ghost_setup_db_password }} gabnotes_org_prod > /mnt/data/gabnotes.org/db_export/backup.sql

View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
/usr/bin/mysqldump --no-tablespaces -u root --password={{ ghost_db_password }} voyages_lois_augendre_info_prod > /mnt/data/voyages-lois.augendre.info/db_export/backup.sql /usr/bin/mysqldump --no-tablespaces -u root --password={{ ghost_setup_db_password }} voyages_lois_augendre_info_prod > /mnt/data/voyages-lois.augendre.info/db_export/backup.sql

View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
/usr/bin/mysqldump --no-tablespaces -u root --password={{ ghost_db_password }} voyages_coccomagnard_fr_prod > /mnt/data/voyages.coccomagnard.fr/db_export/backup.sql /usr/bin/mysqldump --no-tablespaces -u root --password={{ ghost_setup_db_password }} voyages_coccomagnard_fr_prod > /mnt/data/voyages.coccomagnard.fr/db_export/backup.sql

View file

@ -12,7 +12,7 @@
"connection": { "connection": {
"host": "127.0.0.1", "host": "127.0.0.1",
"user": "ghost-900", "user": "ghost-900",
"password": "{{ item.db_password }}", "password": "{{ ghost_setup_db_password }}",
"database": "gabnotes_org_prod" "database": "gabnotes_org_prod"
} }
}, },
@ -26,7 +26,7 @@
"secure": true, "secure": true,
"auth": { "auth": {
"user": "blog@mg.gabnotes.org", "user": "blog@mg.gabnotes.org",
"pass": "{{ item.mail_password }}" "pass": "{{ ghost_setup_mail_password }}"
} }
} }
}, },

View file

@ -9,7 +9,7 @@
"connection": { "connection": {
"host": "127.0.0.1", "host": "127.0.0.1",
"user": "ghost-310", "user": "ghost-310",
"password": "{{ item.db_password }}", "password": "{{ ghost_setup_db_password }}",
"database": "voyages_coccomagnard_fr_prod" "database": "voyages_coccomagnard_fr_prod"
} }
}, },
@ -23,7 +23,7 @@
"secure": true, "secure": true,
"auth": { "auth": {
"user": "voyages@mg.coccomagnard.fr", "user": "voyages@mg.coccomagnard.fr",
"pass": "{{ item.mail_password }}" "pass": "{{ ghost_setup_mail_password }}"
} }
} }
}, },

View file

@ -9,7 +9,7 @@
"connection": { "connection": {
"host": "127.0.0.1", "host": "127.0.0.1",
"user": "ghost-483", "user": "ghost-483",
"password": "{{ item.db_password }}", "password": "{{ ghost_setup_db_password }}",
"database": "voyages_lois_augendre_info_prod" "database": "voyages_lois_augendre_info_prod"
} }
}, },
@ -23,7 +23,7 @@
"secure": true, "secure": true,
"auth": { "auth": {
"user": "voyages-lois@mg.augendre.info", "user": "voyages-lois@mg.augendre.info",
"pass": "{{ item.mail_password }}" "pass": "{{ ghost_setup_mail_password }}"
} }
} }
}, },

View file

@ -0,0 +1,5 @@
---
ghost_setup_filename: site-com-config.json.j2
ghost_setup_site: site.com
ghost_setup_db_password: 123
ghost_setup_mail_password: 123

View file

@ -0,0 +1,6 @@
---
- name: Restart service
ansible.builtin.command:
cmd: ghost restart
chdir: /mnt/data/{{ ghost_setup_site }}
changed_when: true

View file

@ -0,0 +1,14 @@
---
- name: Write config files
ansible.builtin.template:
src: templates/ghost-config/{{ ghost_setup_filename }}
dest: /mnt/data/{{ ghost_setup_site }}/config.production.json
mode: "0664"
notify:
- Restart service
- name: Ensure service is started
ansible.builtin.command:
cmd: ghost start
chdir: /mnt/data/{{ ghost_setup_site }}
register: start
changed_when: '"Starting Ghost" in start.stdout'