initial role commit

This commit is contained in:
srwadleigh 2024-04-27 01:33:31 +00:00
commit 2200d6f9c7
6 changed files with 211 additions and 0 deletions

25
.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project
# idea
out
*.ipr
*.iws
*.iml
.idea
# gradle
build
.gradle
# other
eclipse
run
# Files from Forge MDK
forge*changelog.txt

20
LICENSE Normal file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2024 Shane Wadleigh
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

21
README.md Normal file
View File

@ -0,0 +1,21 @@
# ansible-roles-so
A simple role to assist with the initial setup of stack orchestrator
- https://github.com/cerc-io/stack-orchestrator/
## Task Configuration
```
- name: Setup stack orchestrator
hosts: somehost
become: true
roles:
- role: so
```
## Deployment
```
ansible-playbook -i hosts site.yml --tags=so --limit=somehost
```

15
defaults/main.yml Normal file
View File

@ -0,0 +1,15 @@
---
so_user_add: false
so_user: so
so_home: "/home/{{ so_user }}"
so_repo_checkout: true
so_repo_update: true
so_repo_dev_setup: false
so_repo_url: git@git.vdb.to:cerc-io/stack-orchestrator.git
so_repo_branch: main
so_repo_path: "{{ so_home }}"
so_bin_get: true
so_bin_path: /usr/local/bin
so_bin_url: https://git.vdb.to/cerc-io/stack-orchestrator/releases/download/latest/laconic-so

38
meta/main.yml Normal file
View File

@ -0,0 +1,38 @@
---
dependencies: []
galaxy_info:
role_name: so
author: srw
description: An Ansible role for configuring https://github.com/cerc-io/stack-orchestrator/
company: "NMD, LLC"
license: "license (BSD, MIT)"
min_ansible_version: "2.10"
platforms:
- name: Fedora
versions:
- all
- name: Debian
versions:
- buster
- bullseye
- bookworm
- name: Ubuntu
versions:
- bionic
- focal
- jammy
- name: Alpine
version:
- all
- name: ArchLinux
versions:
- all
galaxy_tags:
- server
- system
- containers
- docker
- orchestration
- compose
- laconic

92
tasks/main.yml Normal file
View File

@ -0,0 +1,92 @@
---
# currently builtin user creation does not place ssh keys, this could go into common
- name: Setup SO user
tags: so
block:
- name: Add so user
ansible.builtin.user:
name: "{{ so_user }}"
home: "{{ so_home }}"
uid: "{{ so_uid | default(omit) }}"
state: present
#- name: Set authorized key taken from file
# ansible.posix.authorized_key:
# user: "{{ so_user }}"
# state: present
# key: "{{ lookup('file', {{ so_user_keys }}) }}"
when:
- so_user_add == true
- name: Install Latest Stack Orchestrator
tags: so
block:
- name: Check so paths
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ so_user }}"
group: "{{ so_user }}"
mode: 0755
with_items:
- "{{ so_bin_path }}"
- name: Download latest so binary
ansible.builtin.get_url:
url: "{{ so_bin_url }}"
dest: "{{ so_bin_path }}/laconic-so"
owner: root
group: root
mode: 0755
timeout: 60
force: yes
when:
- so_bin_get == true
- name: SO user tasks
tags: so-repo
block:
- name: Check repo paths
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ so_user }}"
group: "{{ so_user }}"
mode: 0755
with_items:
- "{{ so_repo_path }}"
- name: Checkout so repo
become: false
remote_user: "{{ so_user }}"
vars:
ansible_ssh_common_args: "-o ForwardAgent=yes"
ansible.builtin.git:
repo: "{{ so_repo_url }}"
dest: "{{ so_repo_path }}/stack-orchestrator"
update: "{{ so_repo_update }}"
version: "{{ so_repo_branch }}"
accept_hostkey: yes
- name: Setup the local dev environment
ansible.builtin.shell:
cmd: "{{ so_repo_path }}/stack-orchestrator/scripts/developer-mode-setup.sh"
chdir: "{{ so_repo_path }}/stack-orchestrator/"
when:
- so_repo_dev_setup == true
- name: Set path to dev laconic-so
set_fact:
so_bin_path: "{{ so_repo_path }}/stack-orchestrator/venv/bin"
when:
- so_repo_dev_setup == true
when:
- so_repo_checkout == true