mirror of
https://github.com/cwchristerw/tjas-infra
synced 2025-08-08 15:24:35 +00:00
Update data directory location to be static in root user directory
This commit is contained in:
24
init.sh
24
init.sh
@@ -35,32 +35,32 @@ ti-header "Asennetaan PVJJK 1.VOS TJAS Infran riippuvuudet APT-paketinhallinnall
|
|||||||
apt-get install -y python3-pip python3-venv jq git curl lsb-release
|
apt-get install -y python3-pip python3-venv jq git curl lsb-release
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
|
|
||||||
mkdir -p ~/.ssh/keys/pvjjk-1vos-tjas &> /dev/null
|
mkdir -p /root/.ssh/keys/pvjjk-1vos-tjas &> /dev/null
|
||||||
if [[ ! -f ~/.ssh/keys/pvjjk-1vos-tjas/infra ]]
|
if [[ ! -f /root/.ssh/keys/pvjjk-1vos-tjas/infra ]]
|
||||||
then
|
then
|
||||||
ti-header "Generoidaan SSH-avain Infra-repon käyttöön..."
|
ti-header "Generoidaan SSH-avain Infra-repon käyttöön..."
|
||||||
ssh-keygen -f ~/.ssh/keys/pvjjk-1vos-tjas/infra -t ed25519 -N '' -C $(hostname --fqdn)
|
ssh-keygen -f /root/.ssh/keys/pvjjk-1vos-tjas/infra -t ed25519 -N '' -C $(hostname --fqdn)
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ti-header "Luodaan Ansiblelle virtuaalinen ympäristö..."
|
ti-header "Luodaan Ansiblelle virtuaalinen ympäristö..."
|
||||||
python3 -m venv ~/.venv/ansible
|
python3 -m venv /root/.venv/ansible
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
|
|
||||||
ti-header "Asennetaan Ansiblen riippuvuudet..."
|
ti-header "Asennetaan Ansiblen riippuvuudet..."
|
||||||
~/.venv/ansible/bin/pip3 install cryptography dnspython hvac jmespath netaddr pexpect
|
/root/.venv/ansible/bin/pip3 install cryptography dnspython hvac jmespath netaddr pexpect
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
|
|
||||||
ti-header "Asennetaan Ansible..."
|
ti-header "Asennetaan Ansible..."
|
||||||
~/.venv/ansible/bin/pip3 install ansible
|
/root/.venv/ansible/bin/pip3 install ansible
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
|
|
||||||
ti-header "Asennetaan Ansible kokoelmat..."
|
ti-header "Asennetaan Ansible kokoelmat..."
|
||||||
~/.venv/ansible/bin/ansible-galaxy collection install ansible.posix containers.podman --upgrade
|
/root/.venv/ansible/bin/ansible-galaxy collection install ansible.posix containers.podman --upgrade
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
|
|
||||||
ti-header "Lisää SSH-avain Infra-repon käyttöön..."
|
ti-header "Lisää SSH-avain Infra-repon käyttöön..."
|
||||||
cat ~/.ssh/keys/pvjjk-1vos-tjas/infra.pub
|
cat /root/.ssh/keys/pvjjk-1vos-tjas/infra.pub
|
||||||
|
|
||||||
echo -n "Onko avain lisätty Github-repoon? [K/E]"
|
echo -n "Onko avain lisätty Github-repoon? [K/E]"
|
||||||
while [[ -z $SSHKEY_QUESTION || ! -z $SSHKEY_QUESTION && $SSHKEY_QUESTION != "K" ]]
|
while [[ -z $SSHKEY_QUESTION || ! -z $SSHKEY_QUESTION && $SSHKEY_QUESTION != "K" ]]
|
||||||
@@ -69,8 +69,8 @@ do
|
|||||||
done
|
done
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
|
|
||||||
mkdir -p ~/.ansible/vault &> /dev/null
|
mkdir -p /root/.ansible/vault &> /dev/null
|
||||||
if [[ ! -f ~/.ansible/vault/pvjjk-1vos-tjas ]]
|
if [[ ! -f /root/.ansible/vault/pvjjk-1vos-tjas ]]
|
||||||
then
|
then
|
||||||
ti-header "Syötä Ansible Vaultin salasana..."
|
ti-header "Syötä Ansible Vaultin salasana..."
|
||||||
echo -n "Salasana: "
|
echo -n "Salasana: "
|
||||||
@@ -80,14 +80,14 @@ then
|
|||||||
|
|
||||||
if [[ ! -z $VAULT_PASSWORD ]]
|
if [[ ! -z $VAULT_PASSWORD ]]
|
||||||
then
|
then
|
||||||
echo "$VAULT_PASSWORD" > ~/.ansible/vault/pvjjk-1vos-tjas
|
echo "$VAULT_PASSWORD" > /root/.ansible/vault/pvjjk-1vos-tjas
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ti-header "Suoritetaan Infran asennus..."
|
ti-header "Suoritetaan Infran asennus..."
|
||||||
~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d ~/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key ~/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file ~/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t installer
|
/root/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d /root/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key /root/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file /root/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t installer
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
- name: "Deployer - SSH - Add Authorized Keys"
|
- name: "Deployer - SSH - Add Authorized Keys"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: './files/ssh/authorized_keys'
|
src: './files/ssh/authorized_keys'
|
||||||
dest: '~/.ssh/authorized_keys'
|
dest: '/root/.ssh/authorized_keys'
|
||||||
tags:
|
tags:
|
||||||
- ssh
|
- ssh
|
||||||
|
|
||||||
@@ -24,14 +24,14 @@
|
|||||||
|
|
||||||
- name: "Deployer - Yggdrasil - Configure - Create Folder"
|
- name: "Deployer - Yggdrasil - Configure - Create Folder"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "~/data/yggdrasil/"
|
path: "/root/data/yggdrasil/"
|
||||||
state: directory
|
state: directory
|
||||||
tags:
|
tags:
|
||||||
- yggdrasil
|
- yggdrasil
|
||||||
|
|
||||||
- name: "Deployer - Yggdrasil - Configure - Create Subfolders"
|
- name: "Deployer - Yggdrasil - Configure - Create Subfolders"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
dest: '~/data/yggdrasil/{{ item.path }}'
|
dest: '/root/data/yggdrasil/{{ item.path }}'
|
||||||
state: directory
|
state: directory
|
||||||
with_filetree: './files/yggdrasil/'
|
with_filetree: './files/yggdrasil/'
|
||||||
loop_control:
|
loop_control:
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
- name: "Deployer - Yggdrasil - Configure - Generating & Transferring Files"
|
- name: "Deployer - Yggdrasil - Configure - Generating & Transferring Files"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: '{{ item.src }}'
|
src: '{{ item.src }}'
|
||||||
dest: '~/data/yggdrasil/{{ item.path }}'
|
dest: '/root/data/yggdrasil/{{ item.path }}'
|
||||||
register: deployerTaskY1
|
register: deployerTaskY1
|
||||||
with_filetree: './files/yggdrasil/'
|
with_filetree: './files/yggdrasil/'
|
||||||
loop_control:
|
loop_control:
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
containers.podman.podman_image:
|
containers.podman.podman_image:
|
||||||
name: pvjjk-1vos-tjas/nginx
|
name: pvjjk-1vos-tjas/nginx
|
||||||
tag: latest
|
tag: latest
|
||||||
path: "~/data/yggdrasil"
|
path: "/root/data/yggdrasil"
|
||||||
build:
|
build:
|
||||||
format: docker
|
format: docker
|
||||||
force: true
|
force: true
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
|
|
||||||
- name: "Deployer - MariaDB - Create Folder"
|
- name: "Deployer - MariaDB - Create Folder"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: ~/data/mariadb
|
path: /root/data/mariadb
|
||||||
state: directory
|
state: directory
|
||||||
tags:
|
tags:
|
||||||
- mariadb
|
- mariadb
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
restart: on
|
restart: on
|
||||||
network: host
|
network: host
|
||||||
volumes:
|
volumes:
|
||||||
- "~/data/mariadb:/var/lib/mysql"
|
- "/root/data/mariadb:/var/lib/mysql"
|
||||||
restart_policy: always
|
restart_policy: always
|
||||||
env:
|
env:
|
||||||
MYSQL_ROOT_PASSWORD: "{{ config.mariadb.users.root.password }}"
|
MYSQL_ROOT_PASSWORD: "{{ config.mariadb.users.root.password }}"
|
||||||
@@ -207,14 +207,14 @@
|
|||||||
|
|
||||||
- name: "Deployer - PowerDNS - Configure - Create Folder"
|
- name: "Deployer - PowerDNS - Configure - Create Folder"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "~/data/powerdns/"
|
path: "/root/data/powerdns/"
|
||||||
state: directory
|
state: directory
|
||||||
tags:
|
tags:
|
||||||
- powerdns
|
- powerdns
|
||||||
|
|
||||||
- name: "Deployer - PowerDNS - Configure - Create Subfolders"
|
- name: "Deployer - PowerDNS - Configure - Create Subfolders"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
dest: '~/data/powerdns/{{ item.path }}'
|
dest: '/root/data/powerdns/{{ item.path }}'
|
||||||
state: directory
|
state: directory
|
||||||
with_filetree: './files/powerdns/'
|
with_filetree: './files/powerdns/'
|
||||||
loop_control:
|
loop_control:
|
||||||
@@ -227,7 +227,7 @@
|
|||||||
- name: "Deployer - PowerDNS - Configure - Generating & Transferring Files"
|
- name: "Deployer - PowerDNS - Configure - Generating & Transferring Files"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: '{{ item.src }}'
|
src: '{{ item.src }}'
|
||||||
dest: '~/data/powerdns/{{ item.path }}'
|
dest: '/root/data/powerdns/{{ item.path }}'
|
||||||
register: deployerTaskP1
|
register: deployerTaskP1
|
||||||
with_filetree: './files/powerdns/'
|
with_filetree: './files/powerdns/'
|
||||||
loop_control:
|
loop_control:
|
||||||
@@ -253,7 +253,7 @@
|
|||||||
network: host
|
network: host
|
||||||
restart_policy: always
|
restart_policy: always
|
||||||
volumes:
|
volumes:
|
||||||
- "~/data/powerdns/config.conf:/etc/powerdns/pdns.conf:ro"
|
- /root/data/powerdns/config.conf:/etc/powerdns/pdns.conf:ro"
|
||||||
when:
|
when:
|
||||||
- (deployerTaskP1 is defined and deployerTaskP1.changed) or deployerTaskP1 is undefined or (deployerTaskP2 is defined and deployerTaskP2.changed) or deployerTaskP2 is undefined
|
- (deployerTaskP1 is defined and deployerTaskP1.changed) or deployerTaskP1 is undefined or (deployerTaskP2 is defined and deployerTaskP2.changed) or deployerTaskP2 is undefined
|
||||||
tags:
|
tags:
|
||||||
@@ -261,14 +261,14 @@
|
|||||||
|
|
||||||
- name: "Deployer - Nginx - Configure - Create Folder"
|
- name: "Deployer - Nginx - Configure - Create Folder"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "~/data/nginx/"
|
path: "/root/data/nginx/"
|
||||||
state: directory
|
state: directory
|
||||||
tags:
|
tags:
|
||||||
- nginx
|
- nginx
|
||||||
|
|
||||||
- name: "Deployer - Nginx - Configure - Create Subfolders"
|
- name: "Deployer - Nginx - Configure - Create Subfolders"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
dest: '~/data/nginx/{{ item.path }}'
|
dest: '/root/data/nginx/{{ item.path }}'
|
||||||
state: directory
|
state: directory
|
||||||
with_filetree: './files/nginx/'
|
with_filetree: './files/nginx/'
|
||||||
loop_control:
|
loop_control:
|
||||||
@@ -281,7 +281,7 @@
|
|||||||
- name: "Deployer - Nginx - Configure - Generating & Transferring Files"
|
- name: "Deployer - Nginx - Configure - Generating & Transferring Files"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: '{{ item.src }}'
|
src: '{{ item.src }}'
|
||||||
dest: '~/data/nginx/{{ item.path }}'
|
dest: '/root/data/nginx/{{ item.path }}'
|
||||||
register: deployerTaskN1
|
register: deployerTaskN1
|
||||||
with_filetree: './files/nginx/'
|
with_filetree: './files/nginx/'
|
||||||
loop_control:
|
loop_control:
|
||||||
|
@@ -12,14 +12,14 @@
|
|||||||
- "task.stdout.find('0 upgraded, 0 newly installed, 0 to remove') == -1"
|
- "task.stdout.find('0 upgraded, 0 newly installed, 0 to remove') == -1"
|
||||||
|
|
||||||
- name: "Init : Python 3 : Configure - Virtual Environment : Test"
|
- name: "Init : Python 3 : Configure - Virtual Environment : Test"
|
||||||
ansible.builtin.raw: "~/.venv/ansible/bin/pip3"
|
ansible.builtin.raw: "/root/.venv/ansible/bin/pip3"
|
||||||
register: task632
|
register: task632
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
- name: "Init : Python 3 : Configure - Virtual Environment : Delete"
|
- name: "Init : Python 3 : Configure - Virtual Environment : Delete"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "~/.venv/ansible"
|
path: "/root/.venv/ansible"
|
||||||
state: absent
|
state: absent
|
||||||
when:
|
when:
|
||||||
- "task632.stdout.find(\"ModuleNotFoundError: No module named 'pip'\") != -1"
|
- "task632.stdout.find(\"ModuleNotFoundError: No module named 'pip'\") != -1"
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
name: pip
|
name: pip
|
||||||
state: latest
|
state: latest
|
||||||
extra_args: --upgrade
|
extra_args: --upgrade
|
||||||
virtualenv: ~/.venv/ansible
|
virtualenv: /root/.venv/ansible
|
||||||
virtualenv_command: "python3 -m venv"
|
virtualenv_command: "python3 -m venv"
|
||||||
|
|
||||||
- name: "Installer : Tools : Install"
|
- name: "Installer : Tools : Install"
|
||||||
@@ -102,22 +102,22 @@
|
|||||||
name: ansible
|
name: ansible
|
||||||
state: latest
|
state: latest
|
||||||
extra_args: --upgrade
|
extra_args: --upgrade
|
||||||
virtualenv: ~/.venv/ansible
|
virtualenv: /root/.venv/ansible
|
||||||
virtualenv_command: "python3 -m venv"
|
virtualenv_command: "python3 -m venv"
|
||||||
tags:
|
tags:
|
||||||
- ansible
|
- ansible
|
||||||
|
|
||||||
- name: "Installer : Ansible : Create Folder"
|
- name: "Installer : Ansible : Create Folder"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: ~/bin
|
path: /root/bin
|
||||||
state: directory
|
state: directory
|
||||||
tags:
|
tags:
|
||||||
- ansible
|
- ansible
|
||||||
|
|
||||||
- name: "Installer : Ansible : Create Symbolic Links"
|
- name: "Installer : Ansible : Create Symbolic Links"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
src: ~/.venv/ansible/bin/{{ binary }}
|
src: /root/.venv/ansible/bin/{{ binary }}
|
||||||
dest: ~/bin/{{ binary }}
|
dest: /root/bin/{{ binary }}
|
||||||
state: link
|
state: link
|
||||||
vars:
|
vars:
|
||||||
binaries:
|
binaries:
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
name: "{{ library }}"
|
name: "{{ library }}"
|
||||||
state: latest
|
state: latest
|
||||||
extra_args: --upgrade
|
extra_args: --upgrade
|
||||||
virtualenv: ~/.venv/ansible
|
virtualenv: /root/.venv/ansible
|
||||||
virtualenv_command: "python3 -m venv"
|
virtualenv_command: "python3 -m venv"
|
||||||
vars:
|
vars:
|
||||||
libraries:
|
libraries:
|
||||||
@@ -164,7 +164,7 @@
|
|||||||
name: pymysql
|
name: pymysql
|
||||||
state: latest
|
state: latest
|
||||||
extra_args: --upgrade
|
extra_args: --upgrade
|
||||||
virtualenv: ~/.venv/ansible
|
virtualenv: /root/.venv/ansible
|
||||||
virtualenv_command: "python3 -m venv"
|
virtualenv_command: "python3 -m venv"
|
||||||
tags:
|
tags:
|
||||||
- mariadb
|
- mariadb
|
||||||
@@ -184,7 +184,7 @@
|
|||||||
name: "PVJJK 1.VOS TJAS - Infra - Maintenance"
|
name: "PVJJK 1.VOS TJAS - Infra - Maintenance"
|
||||||
hour: "*/3"
|
hour: "*/3"
|
||||||
minute: "0"
|
minute: "0"
|
||||||
job: "~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d ~/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key ~/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file ~/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t maintenance"
|
job: "/root/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d /root/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key /root/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file /root/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t maintenance"
|
||||||
tags:
|
tags:
|
||||||
- cron
|
- cron
|
||||||
|
|
||||||
@@ -192,6 +192,6 @@
|
|||||||
ansible.builtin.cron:
|
ansible.builtin.cron:
|
||||||
name: "PVJJK 1.VOS TJAS - Infra - Deployer"
|
name: "PVJJK 1.VOS TJAS - Infra - Deployer"
|
||||||
minute: "*/5"
|
minute: "*/5"
|
||||||
job: "~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d ~/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key ~/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file ~/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t deployer"
|
job: "/root/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d /root/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key /root/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file /root/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t deployer"
|
||||||
tags:
|
tags:
|
||||||
- cron
|
- cron
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
name: "{{ library }}"
|
name: "{{ library }}"
|
||||||
state: latest
|
state: latest
|
||||||
extra_args: --upgrade
|
extra_args: --upgrade
|
||||||
virtualenv: ~/.venv/ansible
|
virtualenv: /root/.venv/ansible
|
||||||
virtualenv_command: "python3 -m venv"
|
virtualenv_command: "python3 -m venv"
|
||||||
vars:
|
vars:
|
||||||
libraries:
|
libraries:
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
name: ansible
|
name: ansible
|
||||||
state: latest
|
state: latest
|
||||||
extra_args: --upgrade
|
extra_args: --upgrade
|
||||||
virtualenv: ~/.venv/ansible
|
virtualenv: /root/.venv/ansible
|
||||||
virtualenv_command: "python3 -m venv"
|
virtualenv_command: "python3 -m venv"
|
||||||
|
|
||||||
- name: "Maintenance : MariaDB : Dependencies / Python Library : pymysql"
|
- name: "Maintenance : MariaDB : Dependencies / Python Library : pymysql"
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
name: pymysql
|
name: pymysql
|
||||||
state: latest
|
state: latest
|
||||||
extra_args: --upgrade
|
extra_args: --upgrade
|
||||||
virtualenv: ~/.venv/ansible
|
virtualenv: /root/.venv/ansible
|
||||||
virtualenv_command: "python3 -m venv"
|
virtualenv_command: "python3 -m venv"
|
||||||
|
|
||||||
- name: "Maintenance : Podman : Prune"
|
- name: "Maintenance : Podman : Prune"
|
||||||
|
Reference in New Issue
Block a user