wip
This commit is contained in:
parent
b6f1b8d798
commit
da2f3ed44a
|
@ -10,11 +10,12 @@ ANSIBLE_DISKS_NFS_PATH ?= $(NFS_PATH)
|
|||
ANSIBLE_DOCKER_IMAGE_TAG ?= $(DOCKER_IMAGE_TAG)
|
||||
ANSIBLE_DOCKER_REGISTRY ?= $(DOCKER_REGISTRY)
|
||||
ANSIBLE_EXTRA_VARS ?= target=localhost
|
||||
ANSIBLE_GIT_DIRECTORY ?= /src/$(subst $(space),/,$(strip $(call reverse,$(subst ., ,$(APP_REPOSITORY_HOST)))))/$(APP_REPOSITORY_PATH)
|
||||
ANSIBLE_GIT_DIRECTORY ?= /dns/$(subst $(space),/,$(strip $(call reverse,$(subst ., ,$(APP_REPOSITORY_HOST)))))/$(APP_REPOSITORY_PATH)
|
||||
ANSIBLE_GIT_KEY_FILE ?= $(if $(ANSIBLE_SSH_PRIVATE_KEYS),~$(ANSIBLE_USERNAME)/.ssh/$(notdir $(firstword $(ANSIBLE_SSH_PRIVATE_KEYS))))
|
||||
ANSIBLE_GIT_REPOSITORY ?= $(GIT_REPOSITORY)
|
||||
ANSIBLE_GIT_VERSION ?= $(BRANCH)
|
||||
ANSIBLE_INVENTORY ?= ansible/inventories
|
||||
ANSIBLE_MYOS ?= $(ANSIBLE_GIT_DIRECTORY)
|
||||
ANSIBLE_PLAYBOOK ?= ansible/playbook.yml
|
||||
ANSIBLE_SSH_AUTHORIZED_KEYS ?= $(strip $(SSH_AUTHORIZED_KEYS))
|
||||
ANSIBLE_SSH_BASTION_HOSTNAME ?= $(firstword $(SSH_BASTION_HOSTNAME))
|
||||
|
@ -28,7 +29,7 @@ ANSIBLE_USERNAME ?= $(USER)
|
|||
ANSIBLE_VERBOSE ?= $(if $(DEBUG),-vvvv,$(if $(VERBOSE),-v))
|
||||
CMDS += ansible ansible-playbook
|
||||
DOCKER_RUN_OPTIONS += $(if $(DOCKER_INTERNAL_DOCKER_HOST),--add-host=host.docker.internal:$(DOCKER_INTERNAL_DOCKER_HOST))
|
||||
ENV_VARS += ANSIBLE_AWS_ACCESS_KEY_ID ANSIBLE_AWS_DEFAULT_OUTPUT ANSIBLE_AWS_DEFAULT_REGION ANSIBLE_AWS_SECRET_ACCESS_KEY ANSIBLE_CONFIG ANSIBLE_DISKS_NFS_DISK ANSIBLE_DISKS_NFS_OPTIONS ANSIBLE_DISKS_NFS_PATH ANSIBLE_DOCKER_IMAGE_TAG ANSIBLE_DOCKER_REGISTRY ANSIBLE_EXTRA_VARS ANSIBLE_GIT_DIRECTORY ANSIBLE_GIT_KEY_FILE ANSIBLE_GIT_REPOSITORY ANSIBLE_GIT_VERSION ANSIBLE_INVENTORY ANSIBLE_PLAYBOOK ANSIBLE_SSH_AUTHORIZED_KEYS ANSIBLE_SSH_BASTION_HOSTNAME ANSIBLE_SSH_BASTION_USERNAME ANSIBLE_SSH_PRIVATE_IP_RANGE ANSIBLE_SSH_PRIVATE_KEYS ANSIBLE_SSH_PUBLIC_HOSTS ANSIBLE_SSH_USERNAME ANSIBLE_USERNAME ANSIBLE_VERBOSE
|
||||
ENV_VARS += ANSIBLE_AWS_ACCESS_KEY_ID ANSIBLE_AWS_DEFAULT_OUTPUT ANSIBLE_AWS_DEFAULT_REGION ANSIBLE_AWS_SECRET_ACCESS_KEY ANSIBLE_CONFIG ANSIBLE_DISKS_NFS_DISK ANSIBLE_DISKS_NFS_OPTIONS ANSIBLE_DISKS_NFS_PATH ANSIBLE_DOCKER_IMAGE_TAG ANSIBLE_DOCKER_REGISTRY ANSIBLE_EXTRA_VARS ANSIBLE_GIT_DIRECTORY ANSIBLE_GIT_KEY_FILE ANSIBLE_GIT_REPOSITORY ANSIBLE_GIT_VERSION ANSIBLE_INVENTORY ANSIBLE_MYOS ANSIBLE_PLAYBOOK ANSIBLE_SSH_AUTHORIZED_KEYS ANSIBLE_SSH_BASTION_HOSTNAME ANSIBLE_SSH_BASTION_USERNAME ANSIBLE_SSH_PRIVATE_IP_RANGE ANSIBLE_SSH_PRIVATE_KEYS ANSIBLE_SSH_PUBLIC_HOSTS ANSIBLE_SSH_USERNAME ANSIBLE_USERNAME ANSIBLE_VERBOSE
|
||||
|
||||
# function ansible: Call run ansible ANSIBLE_ARGS with arg 1
|
||||
define ansible
|
||||
|
|
|
@ -8,12 +8,11 @@ aws_secret_access_key: "{{ lookup('env','ANSIBLE_AWS_SECRET_ACCESS_KEY') }}"
|
|||
disks_packages:
|
||||
- { "name": "e2fsprogs-extra", "state": "present" }
|
||||
- { "name": "nfs-utils", "state": "present" }
|
||||
git_repositories:
|
||||
hosts_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" }
|
||||
hosts_services:
|
||||
- { "name": "local", "state": "started", "enabled": "yes" }
|
||||
- { "name": "zram", "state": "started", "enabled": "yes" }
|
||||
hosts_user_env:
|
||||
- ANSIBLE_AWS_ACCESS_KEY_ID
|
||||
|
@ -29,9 +28,9 @@ hosts_user_env:
|
|||
- ANSIBLE_GIT_KEY_FILE
|
||||
- ANSIBLE_GIT_REPOSITORY
|
||||
- ANSIBLE_INVENTORY
|
||||
- ANSIBLE_MYOS
|
||||
- ANSIBLE_PLAYBOOK
|
||||
- ENV
|
||||
- MYOS
|
||||
hosts_user_rc_enable: true
|
||||
hosts_user_rc_functions:
|
||||
- { "path": "10_prompt_set", "state": "touch" }
|
||||
|
|
|
@ -6,12 +6,10 @@ disks_packages:
|
|||
- { "name": "xfsprogs", "state": "present" }
|
||||
docker_image_tag: "{{ lookup('env','ANSIBLE_DOCKER_IMAGE_TAG') or 'latest' }}"
|
||||
docker_registry: "{{ lookup('env','ANSIBLE_DOCKER_REGISTRY') }}"
|
||||
git_repositories:
|
||||
hosts_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" }
|
||||
hosts_services:
|
||||
- { "name": "local", "state": "started", "enabled": "yes" }
|
||||
- { "name": "myos", "state": "stopped", "enabled": "yes" }
|
||||
- { "name": "zram", "state": "started", "enabled": "yes" }
|
||||
hosts_user_env:
|
||||
- ANSIBLE_CONFIG
|
||||
|
@ -22,7 +20,7 @@ hosts_user_env:
|
|||
- ANSIBLE_GIT_KEY_FILE
|
||||
- ANSIBLE_GIT_REPOSITORY
|
||||
- ANSIBLE_INVENTORY
|
||||
- ANSIBLE_MYOS
|
||||
- ANSIBLE_PLAYBOOK
|
||||
- ENV
|
||||
- MYOS
|
||||
hosts_user_rc_enable: true
|
||||
|
|
|
@ -23,8 +23,9 @@ docker_registry: "{{ lookup('env','ANSIBLE_DOCKER_REGISTRY') }}"
|
|||
hosts_packages:
|
||||
- { "name": "ansible", "state": "present" }
|
||||
hosts_services:
|
||||
- { "name": "local", "state": "started", "enabled": "yes" }
|
||||
- { "name": "myos", "state": "stopped", "enabled": "yes" }
|
||||
- { "name": "zram", "state": "started", "enabled": "yes" }
|
||||
hosts_update: true
|
||||
hosts_user_env:
|
||||
- ANSIBLE_AWS_ACCESS_KEY_ID
|
||||
- ANSIBLE_AWS_SECRET_ACCESS_KEY
|
||||
|
@ -39,10 +40,10 @@ hosts_user_env:
|
|||
- ANSIBLE_GIT_KEY_FILE
|
||||
- ANSIBLE_GIT_REPOSITORY
|
||||
- ANSIBLE_INVENTORY
|
||||
- ANSIBLE_MYOS
|
||||
- ANSIBLE_PLAYBOOK
|
||||
- COMPOSE_PROJECT_NAME
|
||||
- ENV
|
||||
- MYOS
|
||||
- MYOS_TAGS
|
||||
hosts_user_rc_enable: true
|
||||
hosts_user_rc_functions:
|
||||
|
@ -51,3 +52,5 @@ hosts_user_rc_functions:
|
|||
- { "path": "30_pfetch", "state": "touch" }
|
||||
- { "path": "30_screen_attach", "state": "touch" }
|
||||
- { "path": "40_ssh_add", "state": "touch" }
|
||||
remotes_services:
|
||||
- { "name": "ansible", "state": "stopped", "enabled": "yes" }
|
||||
|
|
|
@ -22,7 +22,7 @@ disks_to_mount:
|
|||
- disk: /dev/sdb
|
||||
fstype: ext4
|
||||
mount_options: defaults
|
||||
mount: /data
|
||||
mount: /data1
|
||||
user: www-data
|
||||
group: www-data
|
||||
disable_periodic_fsck: false
|
||||
|
@ -31,14 +31,10 @@ disks_to_mount:
|
|||
fstype: xfs
|
||||
mount_options: defaults,noatime
|
||||
mount: /data2
|
||||
- device_name: /dev/sdf
|
||||
fstype: ext4
|
||||
mount_options: defaults
|
||||
mount: /data
|
||||
- disk: nfs-host:/nfs/export
|
||||
fstype: nfs
|
||||
mount_options: defaults,noatime
|
||||
mount: /srv/nfs
|
||||
mount: /data3
|
||||
```
|
||||
|
||||
The following filesystems are currently supported:
|
||||
|
|
|
@ -1,25 +1,3 @@
|
|||
---
|
||||
# file: tasks/filesystems-btrfs.yml
|
||||
|
||||
- name: filesystems-btrfs - create filesystem on the first partition
|
||||
when: item.1.stat.exists
|
||||
with_together:
|
||||
- '{{ disks_to_mount }}'
|
||||
- '{{ disks_stat.results }}'
|
||||
filesystem:
|
||||
dev: '{{ item.0.part | default(item.0.disk + "1") }}'
|
||||
force: '{{ item.0.force|d(omit) }}'
|
||||
fstype: '{{ item.0.fstype }}'
|
||||
opts: '{{ item.0.fsopts|d(omit) }}'
|
||||
become: yes
|
||||
|
||||
- name: filesystems-btrfs - disable periodic fsck and reserved space on ext3 or ext4 formatted disks
|
||||
when: "disks_to_mount and ( item.0.fstype == 'ext4' or item.0.fstype == 'ext3' ) and item.0.disable_periodic_fsck|default(false)|bool and item.1.stat.exists"
|
||||
with_together:
|
||||
- '{{ disks_to_mount }}'
|
||||
- '{{ disks_stat.results }}'
|
||||
environment:
|
||||
PATH: "{{ ansible_env.PATH }}:/usr/sbin:/sbin"
|
||||
shell: tune2fs -c0 -i0 -m0 {{ item.0.part | default(item.0.disk + "1") }}
|
||||
become: yes
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file: tasks/packages.yml
|
||||
|
||||
- name: packages - install parted
|
||||
when: disks_to_mount
|
||||
when: disks_to_mount is defined
|
||||
package:
|
||||
name: parted
|
||||
state: present
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file: tasks/services.yml
|
||||
|
||||
- name: services - enable/disable disks services
|
||||
when: ansible_service_mgr|lower != "openrc"
|
||||
when: disks_services is defined and ansible_service_mgr|lower != "openrc"
|
||||
with_items: "{{ disks_services|default([]) }}"
|
||||
service:
|
||||
name: "{{item.name}}"
|
||||
|
@ -11,7 +11,7 @@
|
|||
become: yes
|
||||
|
||||
- name: services - openrc - enable/disable disks services
|
||||
when: ansible_service_mgr|lower == "openrc"
|
||||
when: disks_services is defined and ansible_service_mgr|lower == "openrc"
|
||||
with_items: "{{ disks_services|default([]) }}"
|
||||
service:
|
||||
name: "{{item.name}}"
|
||||
|
|
|
@ -12,10 +12,28 @@ Install and configure the [docker](https://www.docker.com/) daemon
|
|||
docker_check_kernel: '3.10'
|
||||
```
|
||||
|
||||
* `docker_check_machine` - Hosts architecture needed to run docker
|
||||
* `docker_daemon_config_directory` - Path to docker daemon configuration files
|
||||
|
||||
``` yaml
|
||||
docker_check_machine: 'x86_64'
|
||||
docker_daemon_config_directory: '/etc/docker'
|
||||
```
|
||||
|
||||
* `docker_daemon_config_file` - Docker daemon configuration file
|
||||
|
||||
``` yaml
|
||||
docker_daemon_config_file: "{{docker_daemon_config_directory}}/daemon.json"
|
||||
```
|
||||
|
||||
* `docker_daemon_config_file` - Docker daemon configuration file
|
||||
|
||||
``` yaml
|
||||
docker_daemon_config_storage: 'overlay2'
|
||||
```
|
||||
|
||||
* `docker_daemon_config` - docker daemon yaml config
|
||||
|
||||
``` yaml
|
||||
docker_daemon_config: { "storage-driver": "devicemapper" }
|
||||
```
|
||||
|
||||
* `docker_package` - Name of the docker package
|
||||
|
|
|
@ -11,7 +11,7 @@ docker_daemon_config_directory: "/etc/docker"
|
|||
docker_daemon_config_file: "{{docker_daemon_config_directory}}/daemon.json"
|
||||
|
||||
# configure docker daemon storage driver
|
||||
docker_daemon_config_storage: "{% if ansible_cmdline.fstype == 'btrfs'%}btrfs{% endif %}"
|
||||
docker_daemon_config_storage: "overlay2"
|
||||
|
||||
# docker daemon configuration
|
||||
docker_daemon_config: {}
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
docker_daemon_config: "{{ lookup('file',docker_daemon_config_file)|default('{}')|from_json}}"
|
||||
ignore_errors: true
|
||||
|
||||
- name: config - add docker daemon storage configuration for btrfs
|
||||
when: docker_package|length > 0
|
||||
- name: config - add docker daemon storage configuration
|
||||
when: false and docker_package|length > 0
|
||||
template:
|
||||
src: daemon.json.j2
|
||||
dest: "{{docker_daemon_config_file}}"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
- name: myos - register myos.tags
|
||||
set_fact:
|
||||
myos_tags: "{{ lookup('env', 'MYOS_TAGS_JSON')|from_json or lookup('file', '~/.env') }}"
|
||||
myos_tags: "{{ lookup('env', 'MYOS_TAGS_JSON')|from_json }}"
|
||||
tags: debug
|
||||
|
||||
- debug:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# file: tasks/packages.yml
|
||||
|
||||
- name: packages - install/remove docker packages
|
||||
when: docker_packages is defined
|
||||
with_items: "{{ docker_packages|default([]) }}"
|
||||
package: name="{{item.name}}" state="{{item.state}}"
|
||||
become: yes
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file: tasks/services.yml
|
||||
|
||||
- name: services - enable/disable docker services
|
||||
when: ansible_service_mgr|lower != "openrc"
|
||||
when: docker_services is defined and ansible_service_mgr|lower != "openrc"
|
||||
with_items: "{{ docker_services|default([]) }}"
|
||||
service:
|
||||
name: "{{item.name}}"
|
||||
|
@ -11,13 +11,13 @@
|
|||
become: yes
|
||||
|
||||
- name: services - openrc - force service status
|
||||
when: ansible_service_mgr|lower == "openrc"
|
||||
when: docker_services is defined and ansible_service_mgr|lower == "openrc"
|
||||
shell: "kill -0 $(cat /run/{{item.name}}.pid) && [ ! -h /run/openrc/started/{{item.name}} ] && ln -s /etc/init.d/{{item.name}} /run/openrc/started/{{item.name}} && service {{item.name}} restart ||:"
|
||||
with_items: "{{ docker_services|default([]) }}"
|
||||
become: yes
|
||||
|
||||
- name: services - openrc - enable/disable docker services
|
||||
when: ansible_service_mgr|lower == "openrc"
|
||||
when: docker_services is defined and ansible_service_mgr|lower == "openrc"
|
||||
with_items: "{{ docker_services|default([]) }}"
|
||||
service:
|
||||
name: "{{item.name}}"
|
||||
|
|
|
@ -8,6 +8,7 @@ docker_packages:
|
|||
- { "name": "apt-transport-https", "state": "present" }
|
||||
- { "name": "ca-certificates", "state": "present" }
|
||||
- { "name": "curl", "state": "present" }
|
||||
- { "name": "docker-compose", "state": "present" }
|
||||
- { "name": "gnupg2", "state": "present" }
|
||||
- { "name": "software-properties-common", "state": "present" }
|
||||
|
||||
|
|
|
@ -23,6 +23,13 @@ hosts_cloudinit_config:
|
|||
hosts_cloudinit_enable: false
|
||||
```
|
||||
|
||||
* `hosts_git_repositories` - Clone git repositories
|
||||
|
||||
``` yaml
|
||||
hosts_git_repositories:
|
||||
- { "repo": "https://github.com/aynicos/myos", "dest": "/dns/com/github/aynicos/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
|
||||
|
@ -99,7 +106,13 @@ hosts_ssh_public_hosts:
|
|||
hosts_ssh_username: root
|
||||
```
|
||||
|
||||
* `hosts_user_env` - List of environment variables added in ~/.env
|
||||
* `hosts_update` - Update hosts every day
|
||||
|
||||
``` yaml
|
||||
hosts_update: false
|
||||
```
|
||||
|
||||
* `hosts_user_env` - List of environment variables to add in file ~/.myos
|
||||
|
||||
``` yaml
|
||||
hosts_user_env:
|
||||
|
|
|
@ -78,6 +78,9 @@ hosts_cloudinit_config:
|
|||
# enable cloud-init
|
||||
hosts_cloudinit_enable: false
|
||||
|
||||
# git repositories to clone
|
||||
hosts_git_repositories: []
|
||||
|
||||
# packages to install/remove
|
||||
hosts_packages: []
|
||||
|
||||
|
@ -125,7 +128,10 @@ hosts_ssh_public_hosts: "{{ lookup('env','ANSIBLE_SSH_PUBLIC_HOSTS').split(' ')
|
|||
# remote ssh user
|
||||
hosts_ssh_username: "{{ lookup('env','ANSIBLE_SSH_USERNAME') or ansible_user }}"
|
||||
|
||||
# list of environment variables to write to user ~/.env
|
||||
# update hosts every day
|
||||
hosts_update: false
|
||||
|
||||
# list of environment variables to add in ~/.myos
|
||||
hosts_user_env: []
|
||||
|
||||
# run specific functions on user login
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# ~/.profile: executed by the command interpreter for login shells.
|
||||
# set -x
|
||||
umask 027
|
||||
|
||||
# source ~/.*aliases and ~/.*functions files
|
||||
for source in aliases functions; do
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
alias DELETE='resty-delete'
|
||||
alias GET='resty-get'
|
||||
alias HEAD='resty-head'
|
||||
alias OPTIONS='resty-options'
|
||||
alias PATCH='resty-patch'
|
||||
alias POST='resty-post'
|
||||
alias PUT='resty-put'
|
||||
alias TRACE='resty-trace'
|
|
@ -1,2 +0,0 @@
|
|||
gam () { "~/.gam/gam" "$@" ; }
|
||||
gyb () { "~/.gyb/gyb" "$@" ; }
|
|
@ -0,0 +1,2 @@
|
|||
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
|
||||
0 0 * * * root /etc/init.d/myos ansible-pull
|
|
@ -1,24 +1,23 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
### 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
|
||||
# Description: MYOS system call
|
||||
### 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
|
||||
[ -r /etc/default/myos ] && . /etc/default/myos || exit 1
|
||||
type make >/dev/null 2>&1 && [ -d "${MYOS}" ] || exit 2
|
||||
|
||||
# load user config
|
||||
[ -r ~/.myos ] && . ~/.myos
|
||||
|
||||
case "$1" in
|
||||
*)
|
||||
IFS=$'\n'; exec env $(cat ~/.env 2>/dev/null) make -C "${MYOS}" $@
|
||||
IFS=$'\n'; exec sh -c "cd ${MYOS} && exec make $@ $(cat /etc/default/myos ~/.myos 2>/dev/null)"
|
||||
esac
|
||||
|
|
|
@ -9,10 +9,10 @@ start() {
|
|||
/etc/init.d/myos start
|
||||
}
|
||||
|
||||
status() {
|
||||
/etc/init.d/myos ps
|
||||
}
|
||||
|
||||
stop() {
|
||||
/etc/init.d/myos stop
|
||||
}
|
||||
|
||||
status() {
|
||||
/etc/init.d/myos status
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# shellcheck shell=sh
|
||||
# file rc.sh: Call user defined functions
|
||||
## author: Yann "aya" Autissier
|
||||
## license: MIT
|
||||
## version: 20210620
|
||||
## license: GPL
|
||||
## version: 20210714
|
||||
|
||||
case $- in
|
||||
# if this is an interactive shell
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# shellcheck shell=sh
|
||||
# file rc_functions.sh: Define shell functions
|
||||
## author: Yann "aya" Autissier
|
||||
## license: MIT
|
||||
## version: 20210711
|
||||
## license: GPL
|
||||
## version: 20210714
|
||||
|
||||
# function force: Run a command sine die
|
||||
force() {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Call myos ansible-pull
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/etc/init.d/myos ansible-pull
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Call ansible
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 00:00:00
|
||||
Unit=ansible.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
# file: tasks/config.yml
|
||||
|
||||
- name: config - arch != x86 - do not run docker-compose in docker
|
||||
when: ansible_machine|lower != "x86_64"
|
||||
lineinfile: dest="/etc/default/myos" state="present" line="DOCKER=false"
|
||||
become: yes
|
||||
|
||||
- name: config - set MYOS config in /etc/default/myos
|
||||
with_items:
|
||||
- MYOS={{ lookup('env','ANSIBLE_MYOS') }}
|
||||
lineinfile: dest="/etc/default/myos" create="yes" line="{{ item }}" mode="0644"
|
||||
become: yes
|
||||
|
|
@ -9,6 +9,13 @@
|
|||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0644
|
||||
become: yes
|
||||
|
||||
- name: files - copy myos cron file
|
||||
when: hosts_update
|
||||
with_items:
|
||||
- /etc/cron.d/myos
|
||||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0644
|
||||
become: yes
|
||||
|
||||
- name: files - copy binary files
|
||||
with_items:
|
||||
- /etc/init.d/myos
|
||||
|
@ -19,6 +26,8 @@
|
|||
- name: files - systemd - copy files
|
||||
when: ansible_service_mgr|lower == "systemd"
|
||||
with_items:
|
||||
- /etc/systemd/system/ansible.service
|
||||
- /etc/systemd/system/ansible.timer
|
||||
- /etc/systemd/system/myos.service
|
||||
- /etc/systemd/system/zram.service
|
||||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0644
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
# file: tasks/git.yml
|
||||
|
||||
- name: git - clone repositories
|
||||
with_items: "{{ hosts_git_repositories|default([]) }}"
|
||||
git:
|
||||
repo: "{{ item.repo }}"
|
||||
dest: "{{ item.dest|default('/dns') }}"
|
||||
umask: "022"
|
||||
key_file: "{{ item.key_file|default('~/.ssh/id_rsa') }}"
|
||||
version: "{{ item.version|default('HEAD') }}"
|
||||
ignore_errors: true
|
||||
become: yes
|
||||
|
|
@ -10,6 +10,9 @@
|
|||
- import_tasks: cloudinit.yml
|
||||
tags:
|
||||
- cloudinit
|
||||
- import_tasks: config.yml
|
||||
tags:
|
||||
- cloudinit
|
||||
- import_tasks: dir.yml
|
||||
tags:
|
||||
- dir
|
||||
|
@ -25,6 +28,9 @@
|
|||
- import_tasks: services.yml
|
||||
tags:
|
||||
- services
|
||||
- import_tasks: git.yml
|
||||
tags:
|
||||
- git
|
||||
- import_tasks: ssh.yml
|
||||
tags:
|
||||
- ssh
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file: tasks/services.yml
|
||||
|
||||
- name: services - enable/disable hosts services
|
||||
when: ansible_service_mgr|lower != "openrc"
|
||||
when: hosts_services is defined and ansible_service_mgr|lower != "openrc"
|
||||
with_items: "{{ hosts_services|default([]) }}"
|
||||
service:
|
||||
name: "{{item.name}}"
|
||||
|
@ -11,7 +11,7 @@
|
|||
become: yes
|
||||
|
||||
- name: services - openrc - enable/disable hosts services
|
||||
when: ansible_service_mgr|lower == "openrc"
|
||||
when: hosts_services is defined and ansible_service_mgr|lower == "openrc"
|
||||
with_items: "{{ hosts_services|default([]) }}"
|
||||
service:
|
||||
name: "{{item.name}}"
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
copy: src="{{ item }}" dest=~/.ssh/ mode=0400
|
||||
ignore_errors: true
|
||||
|
||||
- name: user - create ~/.env
|
||||
- name: user - create ~/.myos
|
||||
template:
|
||||
src: env.j2
|
||||
dest: ~/.env
|
||||
src: myos.j2
|
||||
dest: ~/.myos
|
||||
force: no
|
||||
mode: 0400
|
||||
|
||||
|
@ -32,13 +32,11 @@
|
|||
with_items: "{{ hosts_user_rc_functions|default([]) }}"
|
||||
file: path="~/.rc.d/{{item.path}}" state="{{item.state}}"
|
||||
|
||||
- name: user - copy ~/.*aliases ~/.*functions ~/.*profile ~/.shrc
|
||||
- name: user - copy ~/.*aliases ~/.*profile ~/.shrc
|
||||
with_items:
|
||||
- ".dircolors_aliases"
|
||||
- ".docker_aliases"
|
||||
- ".resty_aliases"
|
||||
- ".vim_aliases"
|
||||
- ".sh_functions"
|
||||
- ".bash_profile"
|
||||
- ".profile"
|
||||
- ".shrc"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CMDS := exec
|
||||
SERVICE ?= cli
|
||||
-include .env
|
||||
-include .myos
|
||||
|
||||
ansible:
|
||||
@make -C $(ANSIBLE_GIT_DIRECTORY) ansible-run-localhost
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
MYOS={{ lookup('env','ANSIBLE_MYOS') }}
|
||||
{% for var in hosts_user_env|default([]) %}
|
||||
{{var}}={{ lookup('env',var) }}
|
||||
{% endfor %}
|
|
@ -6,6 +6,7 @@
|
|||
git:
|
||||
repo: "{{ item.repo }}"
|
||||
dest: "{{ item.dest|default('/src') }}"
|
||||
umask: "022"
|
||||
key_file: "{{ item.key_file|default('~/.ssh/id_rsa') }}"
|
||||
version: "{{ item.version|default('HEAD') }}"
|
||||
ignore_errors: true
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
---
|
||||
# file: tasks/packages.yml
|
||||
|
||||
- name: packages - install parted
|
||||
when: disks_to_mount
|
||||
package:
|
||||
name: parted
|
||||
state: present
|
||||
become: yes
|
||||
|
||||
- name: packages - install/remove disks packages
|
||||
when: disks_packages is defined
|
||||
with_items: "{{ disks_packages|default([]) }}"
|
||||
- name: packages - install/remove remotes packages
|
||||
when: remotes_packages is defined
|
||||
with_items: "{{ remotes_packages|default([]) }}"
|
||||
package:
|
||||
name: "{{item.name}}"
|
||||
state: "{{item.state}}"
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
---
|
||||
# file: tasks/services.yml
|
||||
|
||||
- name: services - enable/disable disks services
|
||||
when: ansible_service_mgr|lower != "openrc"
|
||||
with_items: "{{ disks_services|default([]) }}"
|
||||
- name: services - enable/disable remotes services
|
||||
when: remotes_services is defined and ansible_service_mgr|lower != "openrc"
|
||||
with_items: "{{ remotes_services|default([]) }}"
|
||||
service:
|
||||
name: "{{item.name}}"
|
||||
state: "{{item.state}}"
|
||||
enabled: "{{item.enabled}}"
|
||||
become: yes
|
||||
|
||||
- name: services - openrc - enable/disable disks services
|
||||
when: ansible_service_mgr|lower == "openrc"
|
||||
with_items: "{{ disks_services|default([]) }}"
|
||||
- name: services - openrc - enable/disable remotes services
|
||||
when: remotes_services is defined and ansible_service_mgr|lower == "openrc"
|
||||
with_items: "{{ remotes_services|default([]) }}"
|
||||
service:
|
||||
name: "{{item.name}}"
|
||||
state: "{{item.state}}"
|
||||
|
|
|
@ -37,7 +37,7 @@ DOCKER_PLUGIN_S3FS_OPTIONS ?= allow_other,nonempty,use_path_request_style,u
|
|||
DOCKER_PLUGIN_S3FS_SECRETKEY ?= $(AWS_SECRET_ACCESS_KEY)
|
||||
DOCKER_PLUGIN_S3FS_REGION ?= eu-west-1
|
||||
DOCKER_PLUGIN_VARS ?= S3FS_ACCESSKEY S3FS_OPTIONS S3FS_SECRETKEY S3FS_REGION
|
||||
DOCKER_REGISTRY ?= docker.io
|
||||
DOCKER_REGISTRY ?= my.os
|
||||
DOCKER_REGISTRY_USERNAME ?= $(USER)
|
||||
DOCKER_REGISTRY_REPOSITORY ?= $(addsuffix /,$(DOCKER_REGISTRY))$(subst $(USER),$(DOCKER_REGISTRY_USERNAME),$(DOCKER_REPOSITORY))
|
||||
DOCKER_REPOSITORY ?= $(subst _,/,$(COMPOSE_PROJECT_NAME))
|
||||
|
|
|
@ -7,7 +7,7 @@ MYOS_TAGS_ARGS ?= $(foreach var,$(filter $(MYOS_TAGS_VARS),$(MA
|
|||
MYOS_TAGS_JSON ?= "{$(foreach var,$(filter $(MYOS_TAGS_VARS),$(MAKE_FILE_VARS)),$(if $($(var)), '$(var)': '$($(var))'$(comma))) }"
|
||||
NFS_DISK ?= $(NFS_HOST):/$(notdir $(SHARED))
|
||||
NFS_OPTIONS ?= rw,rsize=8192,wsize=8192,bg,hard,intr,nfsvers=3,noatime,nodiratime,actimeo=3
|
||||
NFS_PATH ?= /srv/$(subst $(space),/,$(strip $(call reverse,$(subst ., ,$(NFS_HOST)))))$(subst ..,,$(SHARED))
|
||||
NFS_PATH ?= /dns/$(subst $(space),/,$(strip $(call reverse,$(subst ., ,$(NFS_HOST)))))$(subst ..,,$(SHARED))
|
||||
SHELL ?= /bin/sh
|
||||
STACK ?= base
|
||||
|
||||
|
|
Loading…
Reference in New Issue