2022-12-18 23:43:40 +01:00
|
|
|
---
|
2022-12-16 22:16:23 +01:00
|
|
|
- name: "set the user variables"
|
|
|
|
ansible.builtin.import_role:
|
2022-12-18 19:36:21 +01:00
|
|
|
name: "services/include"
|
2022-12-16 22:16:23 +01:00
|
|
|
vars_from: "user"
|
|
|
|
|
|
|
|
- name: "check if hugo is installed"
|
|
|
|
ansible.builtin.stat:
|
|
|
|
path: "/usr/local/bin/hugo"
|
|
|
|
register: services_deploy_www_hugo_path
|
|
|
|
|
|
|
|
- block:
|
|
|
|
|
|
|
|
- name: "install hugo"
|
|
|
|
ansible.builtin.apt:
|
2022-12-18 23:43:40 +01:00
|
|
|
deb: "\
|
|
|
|
https://github.com/gohugoio/hugo/releases/download/\
|
|
|
|
v{{ services_deploy_www_hugo_version }}/\
|
|
|
|
hugo_extended_{{ services_deploy_www_hugo_version }}_Linux-64bit.deb"
|
2022-12-16 22:16:23 +01:00
|
|
|
when:
|
|
|
|
not services_deploy_www_hugo_path.stat.exists
|
|
|
|
|
|
|
|
- name: "pin hugo version"
|
|
|
|
ansible.builtin.template:
|
2023-07-08 10:04:37 +02:00
|
|
|
src: "./hugo/apt"
|
2022-12-16 22:16:23 +01:00
|
|
|
dest: "/etc/apt/preferences.d/hugo"
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
vars:
|
|
|
|
services_deploy_www_hugo_version: "0.56.0"
|
|
|
|
|
|
|
|
- block:
|
|
|
|
|
|
|
|
- name: "configure systemd service"
|
|
|
|
ansible.builtin.template:
|
2023-07-08 10:04:37 +02:00
|
|
|
src: "./systemd/{{ item }}"
|
2022-12-16 22:16:23 +01:00
|
|
|
dest: "{{ services_service_user_home }}/.config/systemd/user/{{ item }}"
|
2022-12-17 00:39:25 +01:00
|
|
|
mode: 0600
|
2022-12-16 22:16:23 +01:00
|
|
|
loop:
|
|
|
|
- "pod-www.service"
|
|
|
|
- "container-www-nginx.service"
|
|
|
|
register: services_deploy_www_systemd_files
|
|
|
|
|
|
|
|
- name: "systemd user daemon reload"
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
daemon_reload: true
|
|
|
|
scope: "user"
|
|
|
|
when:
|
|
|
|
services_deploy_www_systemd_files.changed
|
|
|
|
|
|
|
|
- name: "clone website repository"
|
|
|
|
ansible.builtin.git:
|
2022-12-18 23:43:40 +01:00
|
|
|
repo: "\
|
2023-07-08 15:34:11 +02:00
|
|
|
https://{{ services[services_service_name].repo.user }}:\
|
|
|
|
{{ services[services_service_name].repo.token }}@\
|
2023-08-16 23:21:11 +02:00
|
|
|
git.thenineworlds.net/wojtek/wojciechkozlowski.eu.git"
|
2023-07-18 23:18:00 +02:00
|
|
|
dest: "{{ services_service_user_home }}/.config/service/wojciechkozlowski.eu"
|
2022-12-16 22:16:23 +01:00
|
|
|
recursive: true
|
2023-07-22 23:51:34 +02:00
|
|
|
ignore_errors: true
|
2022-12-16 22:16:23 +01:00
|
|
|
register: services_deploy_www_webiste_git
|
|
|
|
|
|
|
|
- name: "generate static page using hugo"
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: "hugo"
|
2023-07-18 23:18:00 +02:00
|
|
|
chdir: "{{ services_service_user_home }}/.config/service/wojciechkozlowski.eu"
|
2022-12-16 22:16:23 +01:00
|
|
|
when:
|
|
|
|
services_deploy_www_webiste_git.changed
|
|
|
|
|
2023-02-11 16:23:31 +01:00
|
|
|
- name: "get uid"
|
|
|
|
ansible.builtin.getent:
|
|
|
|
database: "passwd"
|
|
|
|
key: "{{ services_service_user_name }}"
|
2022-12-16 22:16:23 +01:00
|
|
|
|
2023-02-11 16:23:31 +01:00
|
|
|
- name: "get service status"
|
|
|
|
ansible.builtin.command: >-
|
|
|
|
systemctl --user show --property ActiveState --value
|
2023-07-19 20:43:28 +02:00
|
|
|
pod-{{ services_service_name }}.service
|
2023-02-11 16:23:31 +01:00
|
|
|
environment:
|
|
|
|
XDG_RUNTIME_DIR: "/run/user/{{ getent_passwd[services_service_user_name].1 }}"
|
|
|
|
changed_when: false
|
|
|
|
register: services_deploy_www_service_active_state
|
2022-12-16 22:16:23 +01:00
|
|
|
|
|
|
|
- name: "restart the service"
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "pod-{{ services_service_name }}.service"
|
2022-12-17 00:39:25 +01:00
|
|
|
state: "restarted"
|
|
|
|
scope: "user"
|
2022-12-16 22:16:23 +01:00
|
|
|
when:
|
|
|
|
services_deploy_www_systemd_files.changed and
|
2023-02-11 16:23:31 +01:00
|
|
|
services_deploy_www_service_active_state.stdout == "active"
|
2022-12-16 22:16:23 +01:00
|
|
|
|
|
|
|
become_user: "{{ services_service_user_name }}"
|