+ Moving over to new ansible role setup

This commit is contained in:
shockrah 2022-01-02 15:10:00 -08:00
parent 5440c508e5
commit b7f779b34f
12 changed files with 193 additions and 58 deletions

57
aws/playbooks/README.md Normal file
View File

@ -0,0 +1,57 @@
Role Name
=========
This role is dedicated to making the setup and administration of a clippable
server a little bit easier for those intending on running their own instance.
There are playbooks for maintaining this service both as a container and as a
service running on System D.
Role Variables
--------------
Vars in: `defaults/main.yml`
* `remote_user`: Default username to use for regular tasks
Set to `admin` by default.
* `remote_app_dir`: Directory to install application files into
Set to `/home/{{remote_user}}/app` by default
This includes things like the server binary and HTML template files.
You only need to worry about this if you're not going to run this
in a container.
* `main_host`
Set to `main` by default.
Host that you intend on targeting.
Dependencies
------------
* community.docker
This is only required if you are planning on using any of the docker playbooks.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
License
-------
GPL V3
Author Information
------------------
Author: Shockrah
Email: dev@shockrah.xyz

View File

@ -0,0 +1,4 @@
---
remote_user: admin
remote_app_dir: "/home/{{remote_user}}/app"
main_host: main

View File

@ -0,0 +1,2 @@
---
# handlers file for playbooks

View File

@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# 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: []
# 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.

View File

@ -0,0 +1,2 @@
---
# tasks file for playbooks

View File

@ -0,0 +1,3 @@
---
- hosts: {{ main_host }}
remote_user: {{ remote_user }}

View File

@ -0,0 +1,59 @@
# WHEN TO USE THIS PLAYBOOK:
# Use this if you're running clippable under systemd
# WHAT THIS PLAYBOOK DOES:
# This playbooks basically takes a build/ directory similar to what the Gitlab
# pipelines generate and uploads those files to the desired directory
---
- hosts: {{ main_host }}
remote_user: {{ remote_user }}
tasks:
- name: Build skeleton root directory
file:
path: '{{remote_app_dir}}'
state: directory
- name: Build skeleton static directory
file:
path: '{{remote_app_dir}}/static'
state: directory
- name: Build skeleton css directory
file:
path: '{{remote_app_dir}}/static/css'
state: directory
- name: Build skeleton js directory
file:
path: '{{remote_app_dir}}/static/js'
state: directory
- name: Build skeleton templates directory
file:
path: '{{remote_app_dir}}/templates'
state: directory
- name: Update Binary installation
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
- { src: ../../build/static/css/style.css, dest: '{{remote_app_dir}}/static/css/'}
- { src: ../../build/static/js/index.js, dest: '{{remote_app_dir}}/static/js/'}
- { src: ../../build/static/js/category.js, dest: '{{remote_app_dir}}/static//js/'}
- { src: ../../build/static/cantfindshit.jpg, dest: '{{remote_app_dir}}/static/'}
- { src: ../../build/static/favicon.png, dest: '{{remote_app_dir}}/static/'}
- { src: ../../build/templates/list.html.tera, dest: '{{remote_app_dir}}/templates/list.html.tera'}
- { src: ../../build/templates/video.html.tera, dest: '{{remote_app_dir}}/templates/video.html.tera'}
- { src: ../../build/Rocket.toml, dest: '{{remote_app_dir}}/'}
- { src: ../../build/server, dest: '{{remote_app_dir}}/'}
- name: Restart web service
become: yes
become_method: sudo
service:
name: app
state: restarted

View File

@ -0,0 +1,2 @@
localhost

View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- playbooks

View File

@ -1,58 +0,0 @@
# This playbooks basically takes a build/ directory similar to what the Gitlab
# pipelines generate and uploads those files to the desired directory
---
- hosts: mainhost
remote_user: admin
vars:
app_dir: /home/admin/app
tasks:
- name: Build skeleton root directory
file:
path: '{{app_dir}}'
state: directory
- name: Build skeleton static directory
file:
path: '{{app_dir}}/static'
state: directory
- name: Build skeleton css directory
file:
path: '{{app_dir}}/static/css'
state: directory
- name: Build skeleton js directory
file:
path: '{{app_dir}}/static/js'
state: directory
- name: Build skeleton templates directory
file:
path: '{{app_dir}}/templates'
state: directory
- name: Update Binary installation
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
- { src: ../../build/static/css/style.css, dest: '{{app_dir}}/static/css/'}
- { src: ../../build/static/js/index.js, dest: '{{app_dir}}/static/js/'}
- { src: ../../build/static/js/category.js, dest: '{{app_dir}}/static//js/'}
- { src: ../../build/static/cantfindshit.jpg, dest: '{{app_dir}}/static/'}
- { src: ../../build/static/favicon.png, dest: '{{app_dir}}/static/'}
- { src: ../../build/templates/list.html.tera, dest: '{{app_dir}}/templates/list.html.tera'}
- { src: ../../build/templates/video.html.tera, dest: '{{app_dir}}/templates/video.html.tera'}
- { src: ../../build/Rocket.toml, dest: '{{app_dir}}/'}
- { src: ../../build/server, dest: '{{app_dir}}/'}
- name: Restart web service
become: yes
become_method: sudo
service:
name: app
state: restarted

View File

@ -0,0 +1,2 @@
---
# vars file for playbooks

5
aws/sample.ini Normal file
View File

@ -0,0 +1,5 @@
# NOTE: sample inventory either use your own inventory file or just
# replace the hostname/ip below
[main]
<HOSTNAME/IP ADDRESS>