From b7f779b34f27fbd3664c0db16f85239f02045b8c Mon Sep 17 00:00:00 2001 From: shockrah Date: Sun, 2 Jan 2022 15:10:00 -0800 Subject: [PATCH] + Moving over to new ansible role setup --- aws/playbooks/README.md | 57 +++++++++++++++++++++++++ aws/playbooks/defaults/main.yml | 4 ++ aws/playbooks/handlers/main.yml | 2 + aws/playbooks/meta/main.yml | 52 +++++++++++++++++++++++ aws/playbooks/tasks/main.yml | 2 + aws/playbooks/tasks/update-docker.yml | 3 ++ aws/playbooks/tasks/update-service.yml | 59 ++++++++++++++++++++++++++ aws/playbooks/tests/inventory | 2 + aws/playbooks/tests/test.yml | 5 +++ aws/playbooks/update-service.yml | 58 ------------------------- aws/playbooks/vars/main.yml | 2 + aws/sample.ini | 5 +++ 12 files changed, 193 insertions(+), 58 deletions(-) create mode 100644 aws/playbooks/README.md create mode 100644 aws/playbooks/defaults/main.yml create mode 100644 aws/playbooks/handlers/main.yml create mode 100644 aws/playbooks/meta/main.yml create mode 100644 aws/playbooks/tasks/main.yml create mode 100644 aws/playbooks/tasks/update-docker.yml create mode 100644 aws/playbooks/tasks/update-service.yml create mode 100644 aws/playbooks/tests/inventory create mode 100644 aws/playbooks/tests/test.yml delete mode 100644 aws/playbooks/update-service.yml create mode 100644 aws/playbooks/vars/main.yml create mode 100644 aws/sample.ini diff --git a/aws/playbooks/README.md b/aws/playbooks/README.md new file mode 100644 index 0000000..e2880d3 --- /dev/null +++ b/aws/playbooks/README.md @@ -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 diff --git a/aws/playbooks/defaults/main.yml b/aws/playbooks/defaults/main.yml new file mode 100644 index 0000000..b92d24d --- /dev/null +++ b/aws/playbooks/defaults/main.yml @@ -0,0 +1,4 @@ +--- +remote_user: admin +remote_app_dir: "/home/{{remote_user}}/app" +main_host: main diff --git a/aws/playbooks/handlers/main.yml b/aws/playbooks/handlers/main.yml new file mode 100644 index 0000000..dc1a439 --- /dev/null +++ b/aws/playbooks/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for playbooks diff --git a/aws/playbooks/meta/main.yml b/aws/playbooks/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/aws/playbooks/meta/main.yml @@ -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. diff --git a/aws/playbooks/tasks/main.yml b/aws/playbooks/tasks/main.yml new file mode 100644 index 0000000..d3850be --- /dev/null +++ b/aws/playbooks/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# tasks file for playbooks diff --git a/aws/playbooks/tasks/update-docker.yml b/aws/playbooks/tasks/update-docker.yml new file mode 100644 index 0000000..0fd3011 --- /dev/null +++ b/aws/playbooks/tasks/update-docker.yml @@ -0,0 +1,3 @@ +--- +- hosts: {{ main_host }} + remote_user: {{ remote_user }} diff --git a/aws/playbooks/tasks/update-service.yml b/aws/playbooks/tasks/update-service.yml new file mode 100644 index 0000000..cd0498f --- /dev/null +++ b/aws/playbooks/tasks/update-service.yml @@ -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 diff --git a/aws/playbooks/tests/inventory b/aws/playbooks/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/aws/playbooks/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/aws/playbooks/tests/test.yml b/aws/playbooks/tests/test.yml new file mode 100644 index 0000000..4c70354 --- /dev/null +++ b/aws/playbooks/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - playbooks diff --git a/aws/playbooks/update-service.yml b/aws/playbooks/update-service.yml deleted file mode 100644 index 563b44b..0000000 --- a/aws/playbooks/update-service.yml +++ /dev/null @@ -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 diff --git a/aws/playbooks/vars/main.yml b/aws/playbooks/vars/main.yml new file mode 100644 index 0000000..c1a2395 --- /dev/null +++ b/aws/playbooks/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for playbooks diff --git a/aws/sample.ini b/aws/sample.ini new file mode 100644 index 0000000..ec17176 --- /dev/null +++ b/aws/sample.ini @@ -0,0 +1,5 @@ +# NOTE: sample inventory either use your own inventory file or just +# replace the hostname/ip below +[main] + +