Port www service

This commit is contained in:
Wojciech Kozlowski 2022-12-16 22:16:23 +01:00
parent c8a9242706
commit b7329cdf58
10 changed files with 111 additions and 51 deletions

View File

@ -26,6 +26,8 @@ vpn_bridge_dnat: "{{ services_host_services | dict2items |
# -------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------
# services # services
# -------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------
services_all_hosts: "{{ groups['asgard'] }}"
services: services:
rproxy: {} rproxy: {}
www: www:

View File

@ -1,3 +0,0 @@
Package: hugo
Pin: version {{ hugo_version }}
Pin-Priority: 999

View File

@ -1,37 +0,0 @@
- block:
- name: Check if hugo is installed
stat:
path: "/usr/local/bin/hugo"
register: hugo_path
- name: Install hugo
become_user: root
apt:
deb: https://github.com/gohugoio/hugo/releases/download/v{{ hugo_version }}/hugo_extended_{{ hugo_version }}_Linux-64bit.deb
when:
not hugo_path.stat.exists
- name: Pin hugo version
become_user: root
template:
src: "./filesystem/{{ ansible_hostname }}/etc/apt/preferences.d/hugo.j2"
dest: "/etc/apt/preferences.d/hugo"
mode: 0644
- name: Clone website repository
git:
repo: https://{{ services[service_name].repo_user }}:{{ services[service_name].repo_token }}@git.wojciechkozlowski.eu/wojtek/wojciechkozlowski.eu.git
dest: "{{ service_home }}/.config/{{ service_user_name }}/wojciechkozlowski.eu"
recursive: yes
register: wojciechkozlowski_eu_git
- name: Generate static page using hugo
command:
cmd: hugo
chdir: "{{ service_home }}/.config/{{ service_user_name }}/wojciechkozlowski.eu"
when:
wojciechkozlowski_eu_git is changed
become_user: "{{ service_user_name }}"
vars:
hugo_version: "0.56.0"

View File

@ -1,12 +1,12 @@
--- ---
- name: "services : zfs" - name: "services : zfs"
hosts: "zfs" hosts: "zfs"
tasks:
- name: "datasets_system" roles:
ansible.builtin.import_role: - role: "datasets/system"
name: "datasets/system"
tags: "services:datasets_system" tags: "services:datasets_system"
tasks:
- name: "datasets_user" - name: "datasets_user"
ansible.builtin.include_role: ansible.builtin.include_role:
name: "datasets/user" name: "datasets/user"
@ -23,11 +23,12 @@
- name: "services : asgard" - name: "services : asgard"
hosts: "asgard" hosts: "asgard"
tasks:
- ansible.builtin.import_role: roles:
name: "setup/system" - role: "setup/system"
tags: "services:setup_system" tags: "services:setup_system"
tasks:
- name: "setup_user" - name: "setup_user"
ansible.builtin.include_role: ansible.builtin.include_role:
name: "setup/user" name: "setup/user"
@ -56,7 +57,19 @@
- "services:{{ services_service_name }}:deploy" - "services:{{ services_service_name }}:deploy"
vars: vars:
services_service_name: "rproxy" services_service_name: "rproxy"
services_all_hosts: "{{ groups['asgard'] }}" tags: "always"
- name: "deploy"
ansible.builtin.include_role:
name: "deploy/www"
apply:
tags:
- "services:{{ services_service_name }}"
- "services:deploy"
- "services:deploy:{{ services_service_name }}"
- "services:{{ services_service_name }}:deploy"
vars:
services_service_name: "www"
tags: "always" tags: "always"
- name: "services : yggdrasil" - name: "services : yggdrasil"
@ -73,5 +86,4 @@
- "services:{{ services_service_name }}:deploy" - "services:{{ services_service_name }}:deploy"
vars: vars:
services_service_name: "lrproxy" services_service_name: "lrproxy"
services_all_hosts: "{{ groups['asgard'] }}"
tags: "always" tags: "always"

View File

@ -36,7 +36,7 @@
register: services_deploy_lrproxy_systemd_files register: services_deploy_lrproxy_systemd_files
- name: "systemd user daemon reload" - name: "systemd user daemon reload"
systemd: ansible.builtin.systemd:
daemon_reload: true daemon_reload: true
scope: "user" scope: "user"
when: when:

View File

@ -36,7 +36,7 @@
register: services_deploy_rproxy_systemd_files register: services_deploy_rproxy_systemd_files
- name: "systemd user daemon reload" - name: "systemd user daemon reload"
systemd: ansible.builtin.systemd:
daemon_reload: true daemon_reload: true
scope: "user" scope: "user"
when: when:

View File

@ -0,0 +1,83 @@
- name: "set the user variables"
ansible.builtin.import_role:
name: "include"
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:
deb: "https://github.com/gohugoio/hugo/releases/download/v{{ services_deploy_www_hugo_version }}/hugo_extended_{{ services_deploy_www_hugo_version }}_Linux-64bit.deb"
when:
not services_deploy_www_hugo_path.stat.exists
- name: "pin hugo version"
ansible.builtin.template:
src: "./hugo/apt.j2"
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:
src: "./systemd/{{ item }}.j2"
dest: "{{ services_service_user_home }}/.config/systemd/user/{{ item }}"
mode: 0644
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:
repo: "https://{{ services[services_service_name].repo_user }}:{{ services[services_service_name].repo_token }}@git.wojciechkozlowski.eu/wojtek/wojciechkozlowski.eu.git"
dest: "{{ services_service_user_home }}/.config/{{ services_service_user_name }}/wojciechkozlowski.eu"
recursive: true
register: services_deploy_www_webiste_git
- name: "generate static page using hugo"
ansible.builtin.command:
cmd: "hugo"
chdir: "{{ services_service_user_home }}/.config/{{ services_service_user_name }}/wojciechkozlowski.eu"
when:
services_deploy_www_webiste_git.changed
- name: "enable the service"
ansible.builtin.systemd:
name: "pod-{{ services_service_name }}.service"
enabled: true
scope: "user"
- name: "start the service"
ansible.builtin.systemd:
name: "pod-{{ services_service_name }}.service"
state: "started"
scope: "user"
register: services_deploy_www_service_start
- name: "restart the service"
ansible.builtin.systemd:
name: "pod-{{ services_service_name }}.service"
state: restarted
scope: user
when:
services_deploy_www_systemd_files.changed and
not services_deploy_www_service_start.changed
become_user: "{{ services_service_user_name }}"

View File

@ -0,0 +1,3 @@
Package: hugo
Pin: version {{ services_deploy_www_hugo_version }}
Pin-Priority: 999