Add media server LXC instances
This commit is contained in:
parent
83f4673e03
commit
f654f8c86d
|
@ -3,3 +3,12 @@
|
||||||
---
|
---
|
||||||
hostname: "{{ inventory_hostname }}"
|
hostname: "{{ inventory_hostname }}"
|
||||||
timezone: Europe/Copenhagen
|
timezone: Europe/Copenhagen
|
||||||
|
|
||||||
|
users:
|
||||||
|
- name: lab_admin
|
||||||
|
comment: System administrator
|
||||||
|
groups:
|
||||||
|
- sudo
|
||||||
|
ssh_keys:
|
||||||
|
- sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIFWZGLov8wPBNxuvnaPK+8vv6wK5hHUVEFzXKsN9QeuBAAAADHNzaDpzYW1zYXB0aQ== ssh:samsapti
|
||||||
|
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPd/4fQV7CL8/KVwbo/phiV5UdXFBIDlkZ+ps8C7FeRf cardno:14 336 332
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
# vim: ft=yaml.ansible
|
|
||||||
# code: language=ansible
|
|
||||||
---
|
|
||||||
users:
|
|
||||||
- name: lab_admin
|
|
||||||
comment: System administrator
|
|
||||||
groups:
|
|
||||||
- sudo
|
|
||||||
ssh_keys:
|
|
||||||
- sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIFWZGLov8wPBNxuvnaPK+8vv6wK5hHUVEFzXKsN9QeuBAAAADHNzaDpzYW1zYXB0aQ== ssh:samsapti
|
|
||||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPd/4fQV7CL8/KVwbo/phiV5UdXFBIDlkZ+ps8C7FeRf cardno:14 336 332
|
|
|
@ -2,19 +2,3 @@
|
||||||
# code: language=ansible
|
# code: language=ansible
|
||||||
---
|
---
|
||||||
data_fs: /data
|
data_fs: /data
|
||||||
|
|
||||||
users:
|
|
||||||
- name: lab_admin
|
|
||||||
comment: System administrator
|
|
||||||
groups:
|
|
||||||
- sudo
|
|
||||||
ssh_keys:
|
|
||||||
- sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIFWZGLov8wPBNxuvnaPK+8vv6wK5hHUVEFzXKsN9QeuBAAAADHNzaDpzYW1zYXB0aQ== ssh:samsapti
|
|
||||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPd/4fQV7CL8/KVwbo/phiV5UdXFBIDlkZ+ps8C7FeRf cardno:14 336 332
|
|
||||||
|
|
||||||
- name: ansible
|
|
||||||
comment: Ansible user
|
|
||||||
groups:
|
|
||||||
- sudo
|
|
||||||
ssh_keys:
|
|
||||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDyAuOqh0vcpLMBa8FFbvrTOgw8N+bcImFzyBspfQDAf ansible
|
|
||||||
|
|
|
@ -4,3 +4,4 @@
|
||||||
fqdn: sapt-labp-app01.prod.servers.sapti.me
|
fqdn: sapt-labp-app01.prod.servers.sapti.me
|
||||||
ansible_host: 192.168.17.30
|
ansible_host: 192.168.17.30
|
||||||
internal_ipv4: 10.2.16.10
|
internal_ipv4: 10.2.16.10
|
||||||
|
virt_type: kvm
|
||||||
|
|
|
@ -4,3 +4,4 @@
|
||||||
fqdn: sapt-labp-db01.prod.servers.sapti.me
|
fqdn: sapt-labp-db01.prod.servers.sapti.me
|
||||||
ansible_host: 192.168.17.40
|
ansible_host: 192.168.17.40
|
||||||
internal_ipv4: 10.2.16.20
|
internal_ipv4: 10.2.16.20
|
||||||
|
virt_type: kvm
|
||||||
|
|
7
host_vars/sapt-labp-mda01.yml
Normal file
7
host_vars/sapt-labp-mda01.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# vim: ft=yaml.ansible
|
||||||
|
# code: language=ansible
|
||||||
|
---
|
||||||
|
fqdn: sapt-labp-mda01.prod.servers.sapti.me
|
||||||
|
ansible_host: 192.168.17.35
|
||||||
|
internal_ipv4: 10.2.16.15
|
||||||
|
virt_type: lxc
|
|
@ -4,3 +4,4 @@
|
||||||
fqdn: sapt-labr-mon01.shrd.servers.sapti.me
|
fqdn: sapt-labr-mon01.shrd.servers.sapti.me
|
||||||
ansible_host: 192.168.17.20
|
ansible_host: 192.168.17.20
|
||||||
internal_ipv4: 10.2.18.20
|
internal_ipv4: 10.2.18.20
|
||||||
|
virt_type: kvm
|
||||||
|
|
|
@ -4,5 +4,6 @@
|
||||||
fqdn: sapt-labr-prx01.shrd.servers.sapti.me
|
fqdn: sapt-labr-prx01.shrd.servers.sapti.me
|
||||||
ansible_host: 192.168.17.10
|
ansible_host: 192.168.17.10
|
||||||
internal_ipv4: 10.2.18.10
|
internal_ipv4: 10.2.18.10
|
||||||
|
virt_type: kvm
|
||||||
|
|
||||||
proxy_mode: global
|
proxy_mode: global
|
||||||
|
|
|
@ -4,5 +4,6 @@
|
||||||
fqdn: sapt-labr-prx02.shrd.servers.sapti.me
|
fqdn: sapt-labr-prx02.shrd.servers.sapti.me
|
||||||
ansible_host: 192.168.17.11
|
ansible_host: 192.168.17.11
|
||||||
internal_ipv4: 10.2.18.11
|
internal_ipv4: 10.2.18.11
|
||||||
|
virt_type: kvm
|
||||||
|
|
||||||
proxy_mode: local
|
proxy_mode: local
|
||||||
|
|
|
@ -4,3 +4,4 @@
|
||||||
fqdn: sapt-labs-app01.stage.servers.sapti.me
|
fqdn: sapt-labs-app01.stage.servers.sapti.me
|
||||||
ansible_host: 192.168.17.50
|
ansible_host: 192.168.17.50
|
||||||
internal_ipv4: 10.2.19.10
|
internal_ipv4: 10.2.19.10
|
||||||
|
virt_type: kvm
|
||||||
|
|
|
@ -4,3 +4,4 @@
|
||||||
fqdn: sapt-labs-db01.stage.servers.sapti.me
|
fqdn: sapt-labs-db01.stage.servers.sapti.me
|
||||||
ansible_host: 192.168.17.60
|
ansible_host: 192.168.17.60
|
||||||
internal_ipv4: 10.2.19.20
|
internal_ipv4: 10.2.19.20
|
||||||
|
virt_type: kvm
|
||||||
|
|
7
host_vars/sapt-labs-mda01.yml
Normal file
7
host_vars/sapt-labs-mda01.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# vim: ft=yaml.ansible
|
||||||
|
# code: language=ansible
|
||||||
|
---
|
||||||
|
fqdn: sapt-labs-mda01.stage.servers.sapti.me
|
||||||
|
ansible_host: 192.168.17.55
|
||||||
|
internal_ipv4: 10.2.19.15
|
||||||
|
virt_type: lxc
|
|
@ -1,12 +1,18 @@
|
||||||
[app_prod]
|
[app_prod]
|
||||||
sapt-labp-app01
|
sapt-labp-app01
|
||||||
|
|
||||||
|
[mda_prod]
|
||||||
|
sapt-labp-mda01
|
||||||
|
|
||||||
[db_prod]
|
[db_prod]
|
||||||
sapt-labp-db01
|
sapt-labp-db01
|
||||||
|
|
||||||
[app_stage]
|
[app_stage]
|
||||||
sapt-labs-app01
|
sapt-labs-app01
|
||||||
|
|
||||||
|
[mda_stage]
|
||||||
|
sapt-labs-mda01
|
||||||
|
|
||||||
[db_stage]
|
[db_stage]
|
||||||
sapt-labs-db01
|
sapt-labs-db01
|
||||||
|
|
||||||
|
@ -39,6 +45,10 @@ monitoring_shrd
|
||||||
app_prod
|
app_prod
|
||||||
app_stage
|
app_stage
|
||||||
|
|
||||||
|
[mediaservers:children]
|
||||||
|
mda_prod
|
||||||
|
mda_stage
|
||||||
|
|
||||||
[dbservers:children]
|
[dbservers:children]
|
||||||
db_prod
|
db_prod
|
||||||
db_stage
|
db_stage
|
||||||
|
|
|
@ -7,7 +7,9 @@ proxy_caddy_version: '2.7.4'
|
||||||
proxy_vars:
|
proxy_vars:
|
||||||
production:
|
production:
|
||||||
app01: "{{ hostvars['sapt-labp-app01'] }}"
|
app01: "{{ hostvars['sapt-labp-app01'] }}"
|
||||||
|
mda01: "{{ hostvars['sapt-labp-mda01'] }}"
|
||||||
staging:
|
staging:
|
||||||
app01: "{{ hostvars['sapt-labs-app01'] }}"
|
app01: "{{ hostvars['sapt-labs-app01'] }}"
|
||||||
|
mda01: "{{ hostvars['sapt-labs-mda01'] }}"
|
||||||
shared:
|
shared:
|
||||||
mon01: "{{ hostvars['sapt-labr-mon01'] }}"
|
mon01: "{{ hostvars['sapt-labr-mon01'] }}"
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
# vim: ft=yaml.ansible
|
# vim: ft=yaml.ansible
|
||||||
# code: language=ansible
|
# code: language=ansible
|
||||||
---
|
---
|
||||||
- name: Restart systemd-resolved
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: systemd-resolved
|
|
||||||
state: restarted
|
|
||||||
|
|
||||||
- name: Reload firewalld
|
- name: Reload firewalld
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: firewalld
|
name: firewalld
|
||||||
state: reloaded
|
state: reloaded
|
||||||
|
|
||||||
|
- name: Restart sshd
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: sshd
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: Restart systemd-resolved
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: systemd-resolved
|
||||||
|
state: restarted
|
98
roles/virt-common/tasks/main.yml
Normal file
98
roles/virt-common/tasks/main.yml
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
# vim: ft=yaml.ansible
|
||||||
|
# code: language=ansible
|
||||||
|
---
|
||||||
|
- name: Set hostname
|
||||||
|
ansible.builtin.hostname:
|
||||||
|
name: "{{ hostname }}"
|
||||||
|
|
||||||
|
- name: Set timezone
|
||||||
|
community.general.timezone:
|
||||||
|
name: "{{ timezone }}"
|
||||||
|
|
||||||
|
- name: Copy hosts file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: hosts.j2
|
||||||
|
dest: /etc/hosts
|
||||||
|
owner: root
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
|
|
||||||
|
- name: Add users
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
comment: "{{ item.comment }}"
|
||||||
|
groups: "{{ item.groups }}"
|
||||||
|
shell: /bin/bash
|
||||||
|
state: present
|
||||||
|
loop: "{{ users }}"
|
||||||
|
|
||||||
|
- name: Add SSH keys to users
|
||||||
|
ansible.posix.authorized_key:
|
||||||
|
user: "{{ item.name }}"
|
||||||
|
key: "{{ item.ssh_keys | join('\n') }}"
|
||||||
|
exclusive: true
|
||||||
|
loop: "{{ users }}"
|
||||||
|
|
||||||
|
- name: Allow passwordless sudo
|
||||||
|
community.general.sudoers:
|
||||||
|
name: passwordless
|
||||||
|
group: sudo
|
||||||
|
host: ALL
|
||||||
|
commands: ALL
|
||||||
|
nopassword: true
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Copy sshd_config
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: sshd_config
|
||||||
|
dest: /etc/ssh/sshd_config
|
||||||
|
owner: root
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
|
validate: /usr/sbin/sshd -t -f %s
|
||||||
|
notify: Restart sshd
|
||||||
|
|
||||||
|
- name: Enable extra repositories
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name:
|
||||||
|
- epel-release
|
||||||
|
- rocky-release-security
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install system packages
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name:
|
||||||
|
- firewalld
|
||||||
|
- haveged
|
||||||
|
- htop
|
||||||
|
- jq
|
||||||
|
- logrotate
|
||||||
|
- mtr
|
||||||
|
- rsyslog
|
||||||
|
update_cache: true
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure services are enabled and running
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: "{{ item }}"
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
loop:
|
||||||
|
- firewalld
|
||||||
|
- haveged
|
||||||
|
- rsyslog
|
||||||
|
|
||||||
|
- name: LKRG installation
|
||||||
|
when: virt_type == 'kvm'
|
||||||
|
block:
|
||||||
|
- name: Install LKRG package
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name: lkrg
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure LKRG is enabled and running
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: lkrg
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
|
||||||
|
- name: Configure firewall
|
||||||
|
ansible.builtin.import_tasks: firewall.yml
|
|
@ -1,44 +0,0 @@
|
||||||
# vim: ft=yaml.ansible
|
|
||||||
# code: language=ansible
|
|
||||||
---
|
|
||||||
- name: Copy hosts file
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: hosts.j2
|
|
||||||
dest: /etc/hosts
|
|
||||||
owner: root
|
|
||||||
mode: u=rw,g=r,o=r
|
|
||||||
|
|
||||||
- name: Enable extra repositories
|
|
||||||
ansible.builtin.dnf:
|
|
||||||
name:
|
|
||||||
- epel-release
|
|
||||||
- rocky-release-security
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Install system packages
|
|
||||||
ansible.builtin.dnf:
|
|
||||||
name:
|
|
||||||
- firewalld
|
|
||||||
- haveged
|
|
||||||
- htop
|
|
||||||
- jq
|
|
||||||
- lkrg
|
|
||||||
- logrotate
|
|
||||||
- mtr
|
|
||||||
- rsyslog
|
|
||||||
update_cache: true
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Ensure services are enabled and running
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: "{{ item }}"
|
|
||||||
enabled: true
|
|
||||||
state: started
|
|
||||||
loop:
|
|
||||||
- firewalld
|
|
||||||
- haveged
|
|
||||||
- lkrg
|
|
||||||
- rsyslog
|
|
||||||
|
|
||||||
- name: Configure firewall
|
|
||||||
ansible.builtin.import_tasks: firewall.yml
|
|
|
@ -1,7 +0,0 @@
|
||||||
# vim: ft=yaml.ansible
|
|
||||||
# code: language=ansible
|
|
||||||
---
|
|
||||||
- name: Restart sshd
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: sshd
|
|
||||||
state: restarted
|
|
|
@ -1,44 +0,0 @@
|
||||||
# vim: ft=yaml.ansible
|
|
||||||
# code: language=ansible
|
|
||||||
---
|
|
||||||
- name: Set hostname
|
|
||||||
ansible.builtin.hostname:
|
|
||||||
name: "{{ hostname }}"
|
|
||||||
|
|
||||||
- name: Set timezone
|
|
||||||
community.general.timezone:
|
|
||||||
name: "{{ timezone }}"
|
|
||||||
|
|
||||||
- name: Add users
|
|
||||||
ansible.builtin.user:
|
|
||||||
name: "{{ item.name }}"
|
|
||||||
comment: "{{ item.comment }}"
|
|
||||||
groups: "{{ item.groups }}"
|
|
||||||
shell: /bin/bash
|
|
||||||
state: present
|
|
||||||
loop: "{{ users }}"
|
|
||||||
|
|
||||||
- name: Add SSH keys to users
|
|
||||||
ansible.posix.authorized_key:
|
|
||||||
user: "{{ item.name }}"
|
|
||||||
key: "{{ item.ssh_keys | join('\n') }}"
|
|
||||||
exclusive: true
|
|
||||||
loop: "{{ users }}"
|
|
||||||
|
|
||||||
- name: Allow passwordless sudo
|
|
||||||
community.general.sudoers:
|
|
||||||
name: passwordless
|
|
||||||
group: sudo
|
|
||||||
host: ALL
|
|
||||||
commands: ALL
|
|
||||||
nopassword: true
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Copy sshd_config
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: sshd_config
|
|
||||||
dest: /etc/ssh/sshd_config
|
|
||||||
owner: root
|
|
||||||
mode: u=rw,g=r,o=r
|
|
||||||
validate: /usr/sbin/sshd -t -f %s
|
|
||||||
notify: Restart sshd
|
|
21
site.yml
21
site.yml
|
@ -13,18 +13,12 @@
|
||||||
# roles:
|
# roles:
|
||||||
# - ctl-common
|
# - ctl-common
|
||||||
|
|
||||||
- name: VM initialization
|
- name: Base configuration
|
||||||
hosts: virtualservers
|
|
||||||
remote_user: root
|
|
||||||
roles:
|
|
||||||
- vm-init
|
|
||||||
|
|
||||||
- name: Base VM configuration
|
|
||||||
hosts: virtualservers
|
hosts: virtualservers
|
||||||
remote_user: ansible
|
remote_user: ansible
|
||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- vm-common
|
- virt-common
|
||||||
|
|
||||||
- name: Docker hosts
|
- name: Docker hosts
|
||||||
hosts: appservers:proxyservers:monitorservers
|
hosts: appservers:proxyservers:monitorservers
|
||||||
|
@ -32,14 +26,21 @@
|
||||||
roles:
|
roles:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
- name: App servers
|
- name: Application servers
|
||||||
hosts: appservers
|
hosts: appservers
|
||||||
remote_user: ansible
|
remote_user: ansible
|
||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- apps
|
- apps
|
||||||
|
|
||||||
- name: DB servers
|
# - name: Media servers
|
||||||
|
# hosts: mediaservers
|
||||||
|
# remote_user: ansible
|
||||||
|
# become: true
|
||||||
|
# roles:
|
||||||
|
# - jellyfin
|
||||||
|
|
||||||
|
- name: Database servers
|
||||||
hosts: dbservers
|
hosts: dbservers
|
||||||
remote_user: ansible
|
remote_user: ansible
|
||||||
become: true
|
become: true
|
||||||
|
|
Loading…
Reference in a new issue