myos
This commit is contained in:
parent
3ffea66ba8
commit
b6f1b8d798
|
@ -1,5 +1,7 @@
|
|||
# CHANGELOG
|
||||
|
||||
## v1.0-alpha
|
||||
## v1.0-alpha - 2021-07-14
|
||||
|
||||
First public release. Code is doc.
|
||||
First public release, code is doc
|
||||
|
||||
* Licenses update to GPL, as freedom should not allow evil to move faster than god
|
||||
|
|
|
@ -8,7 +8,7 @@ aws_secret_access_key: "{{ lookup('env','ANSIBLE_AWS_SECRET_ACCESS_KEY') }}"
|
|||
disks_packages:
|
||||
- { "name": "e2fsprogs-extra", "state": "present" }
|
||||
- { "name": "nfs-utils", "state": "present" }
|
||||
hosts_git_repositories:
|
||||
git_repositories:
|
||||
- { "repo": "{{ lookup('env','ANSIBLE_GIT_REPOSITORY') }}", "dest": "{{ lookup('env','ANSIBLE_GIT_DIRECTORY') }}", "key_file": "{{ lookup('env','ANSIBLE_GIT_KEY_FILE') or '~/.ssh/id_rsa' }}", "version": "{{ lookup('env','ANSIBLE_GIT_VERSION') }}" }
|
||||
hosts_packages:
|
||||
- { "name": "ansible", "state": "present" }
|
||||
|
@ -31,6 +31,7 @@ hosts_user_env:
|
|||
- ANSIBLE_INVENTORY
|
||||
- ANSIBLE_PLAYBOOK
|
||||
- ENV
|
||||
- MYOS
|
||||
hosts_user_rc_enable: true
|
||||
hosts_user_rc_functions:
|
||||
- { "path": "10_prompt_set", "state": "touch" }
|
||||
|
|
|
@ -6,7 +6,7 @@ disks_packages:
|
|||
- { "name": "xfsprogs", "state": "present" }
|
||||
docker_image_tag: "{{ lookup('env','ANSIBLE_DOCKER_IMAGE_TAG') or 'latest' }}"
|
||||
docker_registry: "{{ lookup('env','ANSIBLE_DOCKER_REGISTRY') }}"
|
||||
hosts_git_repositories:
|
||||
git_repositories:
|
||||
- { "repo": "{{ lookup('env','ANSIBLE_GIT_REPOSITORY') }}", "dest": "{{ lookup('env','ANSIBLE_GIT_DIRECTORY') }}", "key_file": "{{ lookup('env','ANSIBLE_GIT_KEY_FILE') or '~/.ssh/id_rsa' }}", "version": "{{ lookup('env','ANSIBLE_GIT_VERSION') }}" }
|
||||
hosts_packages:
|
||||
- { "name": "ansible", "state": "present" }
|
||||
|
@ -24,4 +24,5 @@ hosts_user_env:
|
|||
- ANSIBLE_INVENTORY
|
||||
- ANSIBLE_PLAYBOOK
|
||||
- ENV
|
||||
- MYOS
|
||||
hosts_user_rc_enable: true
|
||||
|
|
|
@ -40,7 +40,10 @@ hosts_user_env:
|
|||
- ANSIBLE_GIT_REPOSITORY
|
||||
- ANSIBLE_INVENTORY
|
||||
- ANSIBLE_PLAYBOOK
|
||||
- COMPOSE_PROJECT_NAME
|
||||
- ENV
|
||||
- MYOS
|
||||
- MYOS_TAGS
|
||||
hosts_user_rc_enable: true
|
||||
hosts_user_rc_functions:
|
||||
- { "path": "10_prompt_set", "state": "touch" }
|
||||
|
|
|
@ -23,13 +23,6 @@ hosts_cloudinit_config:
|
|||
hosts_cloudinit_enable: false
|
||||
```
|
||||
|
||||
* `hosts_git_repositories` - Clone git repositories
|
||||
|
||||
``` yaml
|
||||
hosts_git_repositories:
|
||||
- { "repo": "https://github.com/aya/myos", "dest": "/src/com/github/aya/myos", "key_file": "~/.ssh/id_rsa", "version": "master" }
|
||||
```
|
||||
|
||||
* `hosts_packages` - List of packages to install/remove on your hosts, should be overrided for a specific distro
|
||||
|
||||
``` yaml
|
||||
|
|
|
@ -78,9 +78,6 @@ hosts_cloudinit_config:
|
|||
# enable cloud-init
|
||||
hosts_cloudinit_enable: false
|
||||
|
||||
# git repositories to clone
|
||||
hosts_git_repositories: []
|
||||
|
||||
# packages to install/remove
|
||||
hosts_packages: []
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: myos
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Description: System calls from https://github.com/aynicos/myos
|
||||
### END INIT INFO
|
||||
|
||||
set -e
|
||||
|
||||
# load system configs
|
||||
[ -r /etc/default/myos ] && . /etc/default/myos
|
||||
[ -r /etc/sysconfig/myos ] && . /etc/sysconfig/myos
|
||||
|
||||
# check system config
|
||||
[ -r ~/.env ] && . ~/.env || exit 1
|
||||
type make >/dev/null 2>&1 && [ -d "${MYOS}" ] || exit 2
|
||||
|
||||
case "$1" in
|
||||
*)
|
||||
IFS=$'\n'; exec env $(cat ~/.env 2>/dev/null) make -C "${MYOS}" $@
|
||||
esac
|
|
@ -0,0 +1,18 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
depend() {
|
||||
need localmount swap
|
||||
after bootmisc modules
|
||||
}
|
||||
|
||||
start() {
|
||||
/etc/init.d/myos start
|
||||
}
|
||||
|
||||
stop() {
|
||||
/etc/init.d/myos stop
|
||||
}
|
||||
|
||||
status() {
|
||||
/etc/init.d/myos status
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=System calls from https://github.com/aynicos/myos
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/etc/init.d/myos start
|
||||
ExecStop=/etc/init.d/myos stop
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
- name: files - copy binary files
|
||||
with_items:
|
||||
- /etc/init.d/myos
|
||||
- /etc/init.d/zram
|
||||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0755
|
||||
become: yes
|
||||
|
@ -18,6 +19,7 @@
|
|||
- name: files - systemd - copy files
|
||||
when: ansible_service_mgr|lower == "systemd"
|
||||
with_items:
|
||||
- /etc/systemd/system/myos.service
|
||||
- /etc/systemd/system/zram.service
|
||||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0644
|
||||
become: yes
|
||||
|
@ -25,15 +27,8 @@
|
|||
- name: files - openrc - copy files
|
||||
when: ansible_service_mgr|lower == "openrc"
|
||||
with_items:
|
||||
- /etc/init.d/myos-openrc
|
||||
- /etc/init.d/zram-openrc
|
||||
- /etc/local.d/ansible.start
|
||||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0755
|
||||
become: yes
|
||||
|
||||
- name: files - get remote binary files
|
||||
with_items:
|
||||
- https://raw.githubusercontent.com/dylanaraps/pfetch/master/pfetch
|
||||
get_url: url={{item}} dest=/usr/local/bin owner=root group=root mode=0755
|
||||
ignore_errors: true
|
||||
become: yes
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
- import_tasks: files.yml
|
||||
tags:
|
||||
- files
|
||||
- import_tasks: git.yml
|
||||
tags:
|
||||
- git
|
||||
- import_tasks: groups.yml
|
||||
tags:
|
||||
- groups
|
||||
|
|
|
@ -3,13 +3,13 @@ SERVICE ?= cli
|
|||
-include .env
|
||||
|
||||
ansible:
|
||||
@make -C $(ANSIBLE_GIT_DIRECTORY) ansible-run-localhost $(foreach var,$(ENV_USER_VARS),$(if $($(var)),$(var)='$($(var))'))
|
||||
@make -C $(ANSIBLE_GIT_DIRECTORY) ansible-run-localhost
|
||||
|
||||
ansible-%:
|
||||
@make -C $(ANSIBLE_GIT_DIRECTORY) ansible-run-localhost $(foreach var,$(ENV_USER_VARS),$(if $($(var)),$(var)='$($(var))')) ANSIBLE_TAGS=$*
|
||||
@make -C $(ANSIBLE_GIT_DIRECTORY) ansible-run-localhost ANSIBLE_TAGS=$*
|
||||
|
||||
ansible-pull:
|
||||
@$(foreach var,$(ENV_USER_VARS),$(if $($(var)),$(var)='$($(var))')) $(if $(ANSIBLE_CONFIG),ANSIBLE_CONFIG=$(ANSIBLE_GIT_DIRECTORY)/$(ANSIBLE_CONFIG)) ansible-pull --url $(ANSIBLE_GIT_REPOSITORY) $(if $(ANSIBLE_GIT_KEY_FILE),--key-file $(ANSIBLE_GIT_KEY_FILE)) $(if $(ANSIBLE_GIT_VERSION),--checkout $(ANSIBLE_GIT_VERSION)) $(if $(ANSIBLE_GIT_DIRECTORY),--directory $(ANSIBLE_GIT_DIRECTORY)) $(if $(ANSIBLE_TAGS),--tags $(ANSIBLE_TAGS)) $(if $(ANSIBLE_EXTRA_VARS),--extra-vars '$(ANSIBLE_EXTRA_VARS)') $(if $(findstring true,$(FORCE)),--force) $(if $(findstring true,$(DRYRUN)),--check) --full $(if $(ANSIBLE_INVENTORY),--inventory $(ANSIBLE_INVENTORY)) $(ANSIBLE_VERBOSE) $(ANSIBLE_PLAYBOOK)
|
||||
@$(if $(ANSIBLE_CONFIG),ANSIBLE_CONFIG=$(ANSIBLE_GIT_DIRECTORY)/$(ANSIBLE_CONFIG)) ansible-pull --url $(ANSIBLE_GIT_REPOSITORY) $(if $(ANSIBLE_GIT_KEY_FILE),--key-file $(ANSIBLE_GIT_KEY_FILE)) $(if $(ANSIBLE_GIT_VERSION),--checkout $(ANSIBLE_GIT_VERSION)) $(if $(ANSIBLE_GIT_DIRECTORY),--directory $(ANSIBLE_GIT_DIRECTORY)) $(if $(ANSIBLE_TAGS),--tags $(ANSIBLE_TAGS)) $(if $(ANSIBLE_EXTRA_VARS),--extra-vars '$(ANSIBLE_EXTRA_VARS)') $(if $(findstring true,$(FORCE)),--force) $(if $(findstring true,$(DRYRUN)),--check) --full $(if $(ANSIBLE_INVENTORY),--inventory $(ANSIBLE_INVENTORY)) $(ANSIBLE_VERBOSE) $(ANSIBLE_PLAYBOOK)
|
||||
|
||||
exec:
|
||||
@make -C $(ANSIBLE_GIT_DIRECTORY) exec ARGS='$(ARGS)' DOCKER_NAME=$(COMPOSE_PROJECT_NAME)_$(SERVICE) ENV=$(ENV) DOCKER_RUN_WORKDIR=
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
{% for var in hosts_user_env|default([]) %}
|
||||
{{var}}={{ lookup('env',var) }}
|
||||
{% endfor %}
|
||||
ENV_USER_VARS={{hosts_user_env |default([]) |join(' ')}}
|
||||
|
|
|
@ -66,6 +66,15 @@ aws_secret_access_key: 'YOUR_SECRET_ACCESS_KEY'
|
|||
aws_user: 'root'
|
||||
```
|
||||
|
||||
### Git variables
|
||||
|
||||
* `git_repositories` - Clone git repositories
|
||||
|
||||
``` yaml
|
||||
git_repositories:
|
||||
- { "repo": "https://github.com/aynicos/myos", "dest": "/dns/com/github/aynicos/myos", "key_file": "~/.ssh/id_rsa", "version": "master" }
|
||||
```
|
||||
|
||||
## Example playbook
|
||||
|
||||
``` yaml
|
||||
|
|
|
@ -19,6 +19,9 @@ aws_user: "{{ ansible_user|default('root') }}"
|
|||
# aws_secret_access_key to add in ~/.aws/credentials
|
||||
aws_secret_access_key: 'YOUR_SECRET_ACCESS_KEY'
|
||||
|
||||
# git repositories to clone
|
||||
git_repositories: []
|
||||
|
||||
# packages to install/remove
|
||||
remotes_packages: []
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
# file: tasks/files.yml
|
||||
|
||||
- name: files - get remote binary files
|
||||
with_items:
|
||||
- https://raw.githubusercontent.com/dylanaraps/pfetch/master/pfetch
|
||||
get_url: url={{item}} dest=/usr/local/bin owner=root group=root mode=0755
|
||||
ignore_errors: true
|
||||
become: yes
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# file: tasks/git.yml
|
||||
|
||||
- name: git - clone repositories
|
||||
with_items: "{{ hosts_git_repositories|default([]) }}"
|
||||
with_items: "{{ git_repositories|default([]) }}"
|
||||
git:
|
||||
repo: "{{ item.repo }}"
|
||||
dest: "{{ item.dest|default('/src') }}"
|
|
@ -4,9 +4,15 @@
|
|||
- import_tasks: vars.yml
|
||||
tags:
|
||||
- vars
|
||||
- import_tasks: files.yml
|
||||
tags:
|
||||
- files
|
||||
- import_tasks: packages.yml
|
||||
tags:
|
||||
- packages
|
||||
- import_tasks: git.yml
|
||||
tags:
|
||||
- git
|
||||
- import_tasks: pips.yml
|
||||
tags:
|
||||
- pips
|
||||
|
|
Loading…
Reference in New Issue