diff --git a/playbooks/apps/bin.yaml b/playbooks/apps/bin.yaml index 93d3f87..8c1f8b2 100644 --- a/playbooks/apps/bin.yaml +++ b/playbooks/apps/bin.yaml @@ -18,7 +18,7 @@ with_fileglob: - templates/bin/*.j2 vars: - ghost_db_password: !vault | + ghost_setup_db_password: !vault | $ANSIBLE_VAULT;1.1;AES256 35343430343439653064613033383830396264306538376535346637613166376663393062353132 6537386534656239333731313938653539643165323532380a336162663839303339623266383662 diff --git a/playbooks/apps/ghost-config.yaml b/playbooks/apps/ghost-config.yaml index ec1b608..b70197e 100644 --- a/playbooks/apps/ghost-config.yaml +++ b/playbooks/apps/ghost-config.yaml @@ -3,78 +3,68 @@ hosts: servers gather_facts: false tasks: - - name: Write config files - ansible.builtin.template: - src: templates/ghost-config/{{ item.filename }} - dest: /mnt/data/{{ item.site }}/config.production.json - mode: "0664" - notify: - - Restart service - loop_control: - label: "{{ item.site }}" - loop: - - filename: gabnotes-org-config.json.j2 - site: gabnotes.org - db_password: !vault | - $ANSIBLE_VAULT;1.1;AES256 - 66306233626430393737653333313461666665363936376465623137656561356431373666363032 - 6537313234336331626464336434343462623264633463330a353165396163653666636333633537 - 33353464393836623861633238663336336465326435613638613734613433386537663635666332 - 6338343039393737310a356335666632303062353336613364323165633239323032346239376262 - 32323862393264326162383761653163353731363331326337633461643364373936 - mail_password: !vault | - $ANSIBLE_VAULT;1.1;AES256 - 61313164316335333431656136326636353535643363623665326565303961356234353362646261 - 3339616561643434376163613962366631303863313263310a323330316230333864636232386632 - 36363966303861396161373031343865323639383634323131633761666137663766353165333265 - 3630333962383338650a326166383635636533656363613865323065396537396664663132303766 - 62346530353634383935303031343737326335326361313765393664613236356364313161373834 - 35396435303337643330393266376139616164613730643037303039633337343262303335616366 - 373032363533393263323835363666623966 - - filename: voyages-coccomagnard-fr-config.json.j2 - site: voyages.coccomagnard.fr - db_password: !vault | - $ANSIBLE_VAULT;1.1;AES256 - 33623632396330303536366136313438623138366231333063613539303538303761386264623239 - 3266366633343936356564636131303939636330336335390a313430346536666239656562393238 - 32373533373663656435306239643638313937623631366262393462306138323061333961363938 - 3239373062613138660a393933393436633166303837303263356232336666386336346366373934 - 38346330616639646666616161613865643461643965333237353936663933336533 - mail_password: !vault | - $ANSIBLE_VAULT;1.1;AES256 - 33386530613164633962393133316231613664623761336237353335336430313637356430306430 - 3837373934336361636461343338643737653839396336340a633130613038666534653865303338 - 64343366663330653737653638326263383836343762386332346339366465363966346432333631 - 6665396333303462620a636335663266316566636536613630313336636463646430333935373965 - 62653636613263303066333833623637653532663939656339376636356261666235656562336661 - 36376233386235393164363064373733623330306362343039623465303134313434366433383863 - 656136646536333065616631336235623430 - - filename: voyages-lois-augendre-info-config.json.j2 - site: voyages-lois.augendre.info - db_password: !vault | - $ANSIBLE_VAULT;1.1;AES256 - 30623130336131633738353931653239623133326265363862353530303232633333383462663330 - 3935333936383663326162653864623630396363666131390a393532336531663262616431396165 - 33303236363739636665616636326262336532623234666263363563633962343734613565373031 - 3139313038663432370a623363366436643862343734393334306162376634366637616536303035 - 32653739373732613930376336636332343333643436633261616561633034623566 - mail_password: !vault | - $ANSIBLE_VAULT;1.1;AES256 - 35353737376566653462393530613034353763643166626432613836663638636562303762343133 - 6132313762353565646531613336663336313765623430310a616438613433333632343933373330 - 62356661626437306265313061636634613263613633353433653330653862633639376462353637 - 3739313432356262330a626432386536663638646539323861356564616436386464366333303564 - 35303230623365636362323733623531343335376361313430373936663836353132643834643664 - 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 }}" + - name: Setup ghost gabnotes.org + ansible.builtin.include_role: + name: ghost_setup + vars: + ghost_setup_filename: gabnotes-org-config.json.j2 + ghost_setup_site: gabnotes.org + ghost_setup_db_password: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 66306233626430393737653333313461666665363936376465623137656561356431373666363032 + 6537313234336331626464336434343462623264633463330a353165396163653666636333633537 + 33353464393836623861633238663336336465326435613638613734613433386537663635666332 + 6338343039393737310a356335666632303062353336613364323165633239323032346239376262 + 32323862393264326162383761653163353731363331326337633461643364373936 + ghost_setup_mail_password: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 61313164316335333431656136326636353535643363623665326565303961356234353362646261 + 3339616561643434376163613962366631303863313263310a323330316230333864636232386632 + 36363966303861396161373031343865323639383634323131633761666137663766353165333265 + 3630333962383338650a326166383635636533656363613865323065396537396664663132303766 + 62346530353634383935303031343737326335326361313765393664613236356364313161373834 + 35396435303337643330393266376139616164613730643037303039633337343262303335616366 + 373032363533393263323835363666623966 + - name: Setup ghost voyages.coccomagnard.fr + ansible.builtin.include_role: + 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 + 33623632396330303536366136313438623138366231333063613539303538303761386264623239 + 3266366633343936356564636131303939636330336335390a313430346536666239656562393238 + 32373533373663656435306239643638313937623631366262393462306138323061333961363938 + 3239373062613138660a393933393436633166303837303263356232336666386336346366373934 + 38346330616639646666616161613865643461643965333237353936663933336533 + ghost_setup_mail_password: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 33386530613164633962393133316231613664623761336237353335336430313637356430306430 + 3837373934336361636461343338643737653839396336340a633130613038666534653865303338 + 64343366663330653737653638326263383836343762386332346339366465363966346432333631 + 6665396333303462620a636335663266316566636536613630313336636463646430333935373965 + 62653636613263303066333833623637653532663939656339376636356261666235656562336661 + 36376233386235393164363064373733623330306362343039623465303134313434366433383863 + 656136646536333065616631336235623430 + - name: Setup ghost voyages-lois.augendre.info + ansible.builtin.include_role: + 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 + 30623130336131633738353931653239623133326265363862353530303232633333383462663330 + 3935333936383663326162653864623630396363666131390a393532336531663262616431396165 + 33303236363739636665616636326262336532623234666263363563633962343734613565373031 + 3139313038663432370a623363366436643862343734393334306162376634366637616536303035 + 32653739373732613930376336636332343333643436633261616561633034623566 + ghost_setup_mail_password: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 35353737376566653462393530613034353763643166626432613836663638636562303762343133 + 6132313762353565646531613336663336313765623430310a616438613433333632343933373330 + 62356661626437306265313061636634613263613633353433653330653862633639376462353637 + 3739313432356262330a626432386536663638646539323861356564616436386464366333303564 + 35303230623365636362323733623531343335376361313430373936663836353132643834643664 + 6163326436323961636462616430366364626532323861656436 diff --git a/playbooks/apps/templates/bin/dump-gabnotes.org.j2 b/playbooks/apps/templates/bin/dump-gabnotes.org.j2 index 0538df0..b2f3540 100755 --- a/playbooks/apps/templates/bin/dump-gabnotes.org.j2 +++ b/playbooks/apps/templates/bin/dump-gabnotes.org.j2 @@ -1,3 +1,3 @@ #!/bin/bash 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 diff --git a/playbooks/apps/templates/bin/dump-voyages-lois.augendre.info.j2 b/playbooks/apps/templates/bin/dump-voyages-lois.augendre.info.j2 index 86f763c..1ab19f9 100755 --- a/playbooks/apps/templates/bin/dump-voyages-lois.augendre.info.j2 +++ b/playbooks/apps/templates/bin/dump-voyages-lois.augendre.info.j2 @@ -1,3 +1,3 @@ #!/bin/bash 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 diff --git a/playbooks/apps/templates/bin/dump-voyages.coccomagnard.fr.j2 b/playbooks/apps/templates/bin/dump-voyages.coccomagnard.fr.j2 index aa2e308..166a24c 100755 --- a/playbooks/apps/templates/bin/dump-voyages.coccomagnard.fr.j2 +++ b/playbooks/apps/templates/bin/dump-voyages.coccomagnard.fr.j2 @@ -1,3 +1,3 @@ #!/bin/bash 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 diff --git a/playbooks/apps/templates/ghost-config/gabnotes-org-config.json.j2 b/playbooks/apps/templates/ghost-config/gabnotes-org-config.json.j2 index a6f05d3..ec34a06 100644 --- a/playbooks/apps/templates/ghost-config/gabnotes-org-config.json.j2 +++ b/playbooks/apps/templates/ghost-config/gabnotes-org-config.json.j2 @@ -12,7 +12,7 @@ "connection": { "host": "127.0.0.1", "user": "ghost-900", - "password": "{{ item.db_password }}", + "password": "{{ ghost_setup_db_password }}", "database": "gabnotes_org_prod" } }, @@ -26,7 +26,7 @@ "secure": true, "auth": { "user": "blog@mg.gabnotes.org", - "pass": "{{ item.mail_password }}" + "pass": "{{ ghost_setup_mail_password }}" } } }, diff --git a/playbooks/apps/templates/ghost-config/voyages-coccomagnard-fr-config.json.j2 b/playbooks/apps/templates/ghost-config/voyages-coccomagnard-fr-config.json.j2 index 17bca3f..0fe1f31 100644 --- a/playbooks/apps/templates/ghost-config/voyages-coccomagnard-fr-config.json.j2 +++ b/playbooks/apps/templates/ghost-config/voyages-coccomagnard-fr-config.json.j2 @@ -9,7 +9,7 @@ "connection": { "host": "127.0.0.1", "user": "ghost-310", - "password": "{{ item.db_password }}", + "password": "{{ ghost_setup_db_password }}", "database": "voyages_coccomagnard_fr_prod" } }, @@ -23,7 +23,7 @@ "secure": true, "auth": { "user": "voyages@mg.coccomagnard.fr", - "pass": "{{ item.mail_password }}" + "pass": "{{ ghost_setup_mail_password }}" } } }, diff --git a/playbooks/apps/templates/ghost-config/voyages-lois-augendre-info-config.json.j2 b/playbooks/apps/templates/ghost-config/voyages-lois-augendre-info-config.json.j2 index fd27446..25059e9 100644 --- a/playbooks/apps/templates/ghost-config/voyages-lois-augendre-info-config.json.j2 +++ b/playbooks/apps/templates/ghost-config/voyages-lois-augendre-info-config.json.j2 @@ -9,7 +9,7 @@ "connection": { "host": "127.0.0.1", "user": "ghost-483", - "password": "{{ item.db_password }}", + "password": "{{ ghost_setup_db_password }}", "database": "voyages_lois_augendre_info_prod" } }, @@ -23,7 +23,7 @@ "secure": true, "auth": { "user": "voyages-lois@mg.augendre.info", - "pass": "{{ item.mail_password }}" + "pass": "{{ ghost_setup_mail_password }}" } } }, diff --git a/roles/ghost_setup/defaults/main.yaml b/roles/ghost_setup/defaults/main.yaml new file mode 100644 index 0000000..254330b --- /dev/null +++ b/roles/ghost_setup/defaults/main.yaml @@ -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 diff --git a/roles/ghost_setup/handlers/main.yaml b/roles/ghost_setup/handlers/main.yaml new file mode 100644 index 0000000..8d68f1f --- /dev/null +++ b/roles/ghost_setup/handlers/main.yaml @@ -0,0 +1,6 @@ +--- +- name: Restart service + ansible.builtin.command: + cmd: ghost restart + chdir: /mnt/data/{{ ghost_setup_site }} + changed_when: true diff --git a/roles/ghost_setup/tasks/main.yaml b/roles/ghost_setup/tasks/main.yaml new file mode 100644 index 0000000..2a34c2e --- /dev/null +++ b/roles/ghost_setup/tasks/main.yaml @@ -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'