Create Role
This commit is contained in:
parent
27caf9156c
commit
a08f49a53a
80
README.md
80
README.md
@ -1,3 +1,79 @@
|
|||||||
# ansible-role-hugo-deploy
|
ansible-role-hugo-deploy
|
||||||
|
=========
|
||||||
|
|
||||||
This role is used to deploy a website managed by Hugo on a webserver.
|
This role is used to deploy a website managed by Hugo on a webserver.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
None, any package needed is downloaded by the role itself.
|
||||||
|
|
||||||
|
It's written for Debian tho.
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
```
|
||||||
|
hugo_deploy_site_url: ""
|
||||||
|
```
|
||||||
|
The URL used to build the website with Hugo. Used for the `--baseURL` argument.
|
||||||
|
|
||||||
|
```
|
||||||
|
hugo_deploy_website_git_url: ""
|
||||||
|
```
|
||||||
|
|
||||||
|
The git repo's URL for the website.
|
||||||
|
|
||||||
|
```
|
||||||
|
hugo_deploy_download_path: "/opt/hugo_deploy"
|
||||||
|
```
|
||||||
|
|
||||||
|
Where, on the server, will the website will be downloaded before it's built.
|
||||||
|
|
||||||
|
```
|
||||||
|
hugo_deploy_dest_webroot: "/var/www/{{hugo_deploy_site_url}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
Where to copy the website once it's built.
|
||||||
|
|
||||||
|
```
|
||||||
|
hugo_deploy_build_openring: no
|
||||||
|
```
|
||||||
|
|
||||||
|
This role can use [Openring](https://git.sr.ht/~sircmpwn/openring) to build a Openring.
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
become: yes
|
||||||
|
hosts: all
|
||||||
|
vars_files:
|
||||||
|
- vars.yml
|
||||||
|
tasks:
|
||||||
|
- name: "Include ansible-role-hugo-deploy"
|
||||||
|
include_role:
|
||||||
|
name: "ansible-role-hugo-deploy"
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
hugo_deploy_site_url: "https://example.com"
|
||||||
|
hugo_deploy_website_git_url: "http://git.example.xyz/user/blog.git"
|
||||||
|
hugo_deploy_download_path: "/opt/hugo_deploy"
|
||||||
|
hugo_deploy_build_openring: yes
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
AGPLv3
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Built by [N07070]( https://n07070.xyz).
|
||||||
|
8
defaults/main.yml
Normal file
8
defaults/main.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
# defaults file for ansible-role-hugo-deploy
|
||||||
|
|
||||||
|
hugo_deploy_site_url: ""
|
||||||
|
hugo_deploy_website_git_url: ""
|
||||||
|
hugo_deploy_download_path: "/opt/hugo_deploy"
|
||||||
|
hugo_deploy_dest_webroot: "/var/www/{{hugo_deploy_site_url}}"
|
||||||
|
hugo_deploy_build_openring: no
|
2
handlers/main.yml
Normal file
2
handlers/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for ansible-role-hugo-deploy
|
55
meta/main.yml
Normal file
55
meta/main.yml
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
galaxy_info:
|
||||||
|
author: nono
|
||||||
|
description: This role is used to deploy a website managed by Hugo on a webserver.
|
||||||
|
role_name: ansible_role_hugo_deploy
|
||||||
|
namespace: nono
|
||||||
|
|
||||||
|
# If the issue tracker for your role is not on github, uncomment the
|
||||||
|
# next line and provide a value
|
||||||
|
# issue_tracker_url: http://example.com/issue/tracker
|
||||||
|
|
||||||
|
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||||
|
# - BSD-3-Clause (default)
|
||||||
|
# - MIT
|
||||||
|
# - GPL-2.0-or-later
|
||||||
|
# - GPL-3.0-only
|
||||||
|
# - Apache-2.0
|
||||||
|
# - CC-BY-4.0
|
||||||
|
license: license (GPL-2.0-or-later, MIT, etc)
|
||||||
|
|
||||||
|
min_ansible_version: 2.1
|
||||||
|
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
#
|
||||||
|
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||||
|
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||||
|
# To view available platforms and versions (or releases), visit:
|
||||||
|
# https://galaxy.ansible.com/api/v1/platforms/
|
||||||
|
#
|
||||||
|
# platforms:
|
||||||
|
# - name: Fedora
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 25
|
||||||
|
# - name: SomePlatform
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 1.0
|
||||||
|
# - 7
|
||||||
|
# - 99.99
|
||||||
|
|
||||||
|
galaxy_tags:
|
||||||
|
- hugo
|
||||||
|
- static
|
||||||
|
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||||
|
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||||
|
# remove the '[]' above, if you add tags to this list.
|
||||||
|
#
|
||||||
|
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||||
|
# Maximum 20 tags per role.
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
|
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||||
|
# if you add dependencies to this list.
|
23
molecule/default/INSTALL.rst
Normal file
23
molecule/default/INSTALL.rst
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
*********************************
|
||||||
|
Vagrant driver installation guide
|
||||||
|
*********************************
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
============
|
||||||
|
|
||||||
|
* Vagrant
|
||||||
|
* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop
|
||||||
|
|
||||||
|
Install
|
||||||
|
=======
|
||||||
|
|
||||||
|
Please refer to the `Virtual environment`_ documentation for installation best
|
||||||
|
practices. If not using a virtual environment, please consider passing the
|
||||||
|
widely recommended `'--user' flag`_ when invoking ``pip``.
|
||||||
|
|
||||||
|
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
|
||||||
|
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ pip install 'molecule_vagrant'
|
10
molecule/default/converge.yml
Normal file
10
molecule/default/converge.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
become: yes
|
||||||
|
hosts: all
|
||||||
|
vars_files:
|
||||||
|
- vars.yml
|
||||||
|
tasks:
|
||||||
|
- name: "Include ansible-role-hugo-deploy"
|
||||||
|
include_role:
|
||||||
|
name: "ansible-role-hugo-deploy"
|
16
molecule/default/molecule.yml
Normal file
16
molecule/default/molecule.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: vagrant
|
||||||
|
provider:
|
||||||
|
name: virtualbox
|
||||||
|
platforms:
|
||||||
|
- name: instance
|
||||||
|
box: debian/bullseye64
|
||||||
|
memory: 512
|
||||||
|
cpus: 1
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
6
molecule/default/vars.yml
Normal file
6
molecule/default/vars.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
hugo_deploy_site_url: "localhost"
|
||||||
|
hugo_deploy_website_git_url: ""
|
||||||
|
hugo_deploy_download_path: "/opt/hugo_deploy"
|
||||||
|
hugo_deploy_build_openring: yes
|
10
molecule/default/verify.yml
Normal file
10
molecule/default/verify.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# This is an example playbook to execute Ansible tests.
|
||||||
|
|
||||||
|
- name: Verify
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Example assertion
|
||||||
|
assert:
|
||||||
|
that: true
|
31
tasks/build.yml
Normal file
31
tasks/build.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
- name: Verify the webroot exists
|
||||||
|
file:
|
||||||
|
path: "{{ hugo_deploy_dest_webroot }}"
|
||||||
|
state: directory
|
||||||
|
owner: www-data
|
||||||
|
group: www-data
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Build Openring
|
||||||
|
shell:
|
||||||
|
cmd: go build
|
||||||
|
chdir: "{{ hugo_deploy_download_path}}/tools/openring"
|
||||||
|
|
||||||
|
- name: Generate Openring
|
||||||
|
shell:
|
||||||
|
cmd: ./openring -s https://www.laquadrature.net/feed -s https://blog.mondediplo.net/rss/ -s https://solar.lowtechmagazine.com/feeds/all-en.rss.xml < {{hugo_deploy_download_path}}/themes/blogotheme/layouts/partials/openring-in.html > {{hugo_deploy_download_path}}/themes/blogotheme/layouts/partials/openring-out.html
|
||||||
|
chdir: "{{hugo_deploy_download_path}}/tools/openring/"
|
||||||
|
when: hugo_deploy_build_openring
|
||||||
|
|
||||||
|
- name: Building the website with Hugo
|
||||||
|
shell:
|
||||||
|
cmd: hugo --themesDir themes --theme blogotheme --baseURL="http://{{ hugo_deploy_site_url }}" --enableGitInfo --minify --templateMetrics
|
||||||
|
chdir: "{{ hugo_deploy_download_path }}"
|
||||||
|
|
||||||
|
- name: Copy the website to it's webroot
|
||||||
|
copy:
|
||||||
|
remote_src: yes
|
||||||
|
src: "{{ hugo_deploy_download_path }}/public/"
|
||||||
|
dest: "{{ hugo_deploy_dest_webroot }}"
|
22
tasks/dependecies.yml
Normal file
22
tasks/dependecies.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
- name: Update the APT cache
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: Make sure Hugo is installed
|
||||||
|
package:
|
||||||
|
name: hugo
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Make sure git is installed
|
||||||
|
package:
|
||||||
|
name: git
|
||||||
|
state: present
|
||||||
|
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Make sure Golang is installed
|
||||||
|
package:
|
||||||
|
name: golang
|
||||||
|
state: present
|
||||||
|
when: hugo_deploy_build_openring
|
13
tasks/import-website.yml
Normal file
13
tasks/import-website.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
- name: Verify that the path to download the website exists
|
||||||
|
file:
|
||||||
|
path: "{{ hugo_deploy_download_path }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Clone the git repo for the website
|
||||||
|
git:
|
||||||
|
repo: "{{ hugo_deploy_website_git_url }}"
|
||||||
|
dest: "{{ hugo_deploy_download_path }}"
|
||||||
|
accept_hostkey: yes
|
||||||
|
force: yes
|
11
tasks/main.yml
Normal file
11
tasks/main.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
# tasks file for ansible-role-hugo-deploy
|
||||||
|
|
||||||
|
- name: Verify dependecies
|
||||||
|
import_tasks: dependecies.yml
|
||||||
|
|
||||||
|
- name: Import the website
|
||||||
|
import_tasks: import-website.yml
|
||||||
|
|
||||||
|
- name: Build the website
|
||||||
|
import_tasks: build.yml
|
2
tests/inventory
Normal file
2
tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
5
tests/test.yml
Normal file
5
tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- ansible-role-hugo-deploy
|
2
vars/main.yml
Normal file
2
vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for ansible-role-hugo-deploy
|
Loading…
Reference in New Issue
Block a user