split tasks per distribution, add msmtp
This commit is contained in:
parent
57e5333dc5
commit
042be1c6ea
60
tasks/alpine.yml
Normal file
60
tasks/alpine.yml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
---
|
||||||
|
- name: install basics
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- /sbin/apk add -U python3 dropbear openssh-client-default wget"
|
||||||
|
|
||||||
|
- name: setup ssh
|
||||||
|
include: ssh.yml
|
||||||
|
|
||||||
|
- name: enable dropbear
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- rc-update add dropbear"
|
||||||
|
|
||||||
|
- name: enable dropbear
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- rc-service dropbear restart"
|
||||||
|
|
||||||
|
- name: install software
|
||||||
|
apk: name={{ alpine_software }} state=present update_cache=yes
|
||||||
|
|
||||||
|
- name: deploy syslog config
|
||||||
|
copy:
|
||||||
|
src: alpine/syslog.conf
|
||||||
|
dest: /etc/conf.d/syslog
|
||||||
|
mode: 0644
|
||||||
|
notify:
|
||||||
|
- restart container
|
||||||
|
|
||||||
|
- name: deploy update script
|
||||||
|
copy:
|
||||||
|
src: alpine/update.sh
|
||||||
|
dest: /etc/periodic/daily/update
|
||||||
|
mode: 0755
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
- name: deploy mail aliases
|
||||||
|
template:
|
||||||
|
src: aliases.j2
|
||||||
|
dest: /etc/aliases
|
||||||
|
mode: 0644
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
- name: deploy msmtprc
|
||||||
|
template:
|
||||||
|
src: msmtprc.j2
|
||||||
|
dest: /etc/msmtprc
|
||||||
|
mode: 0644
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
- name: symlink sendmail
|
||||||
|
file:
|
||||||
|
src: /usr/bin/msmtp
|
||||||
|
dest: /usr/sbin/sendmail
|
||||||
|
force: yes
|
||||||
|
state: link
|
21
tasks/archlinux.yml
Normal file
21
tasks/archlinux.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- name: install basics
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- /usr/sbin/pacman -Syu --noconfirm python3 dropbear dropbear-scp wget"
|
||||||
|
|
||||||
|
- name: setup ssh
|
||||||
|
include: ssh.yml
|
||||||
|
|
||||||
|
- name: enable dropbear
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- systemctl enable dropbear"
|
||||||
|
|
||||||
|
- name: enable dropbear
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- systemctl restart dropbear"
|
||||||
|
|
||||||
|
- name: install software
|
||||||
|
pacman: name={{ archlinux_software }} state=present update_cache=yes
|
@ -18,7 +18,7 @@
|
|||||||
mode: pull
|
mode: pull
|
||||||
server: https://images.linuxcontainers.org
|
server: https://images.linuxcontainers.org
|
||||||
protocol: simplestreams #lxd # if you get a 404, try setting protocol: simplestreams
|
protocol: simplestreams #lxd # if you get a 404, try setting protocol: simplestreams
|
||||||
alias: alpine/3.14/amd64
|
alias: "{{ container_image }}"
|
||||||
devices: '{ "eth0": {"nictype":"bridged", "parent":"lxd","type":"nic","ipv4.address":"{{ ansible_host }}"} }' # default to {}
|
devices: '{ "eth0": {"nictype":"bridged", "parent":"lxd","type":"nic","ipv4.address":"{{ ansible_host }}"} }' # default to {}
|
||||||
profiles: ["lxd"]
|
profiles: ["lxd"]
|
||||||
wait_for_ipv4_addresses: true
|
wait_for_ipv4_addresses: true
|
||||||
@ -26,55 +26,20 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
connection: local
|
connection: local
|
||||||
|
|
||||||
- name: install basics
|
- name: setup alpine
|
||||||
connection: local
|
include: alpine.yml
|
||||||
delegate_to: localhost
|
when: '"alpine" in container_image'
|
||||||
raw: "lxc exec {{ inventory_hostname }} -- /sbin/apk add -U python3 dropbear openssh-client-default wget"
|
|
||||||
|
|
||||||
- name: setup /root/.ssh
|
- name: setup archlinux
|
||||||
connection: local
|
include: archlinux.yml
|
||||||
delegate_to: localhost
|
when: '"archlinux" in container_image'
|
||||||
raw: "lxc exec {{ inventory_hostname }} -- mkdir -p /root/.ssh"
|
|
||||||
|
|
||||||
- name: get authorized_keys
|
- name: setup rockylinux
|
||||||
connection: local
|
include: rockylinux.yml
|
||||||
delegate_to: localhost
|
when: '"rockylinux" in container_image'
|
||||||
raw: "lxc exec {{ inventory_hostname }} -- wget https://git.br0tkasten.de/br0tkasten/configs/raw/branch/master/dotfiles/authorized_keys -O /root/.ssh/authorized_keys"
|
|
||||||
|
|
||||||
- name: fix permissions
|
|
||||||
connection: local
|
|
||||||
delegate_to: localhost
|
|
||||||
raw: "lxc exec {{ inventory_hostname }} -- chmod 0600 /root/.ssh/authorized_keys"
|
|
||||||
|
|
||||||
- name: enable dropbear
|
|
||||||
connection: local
|
|
||||||
delegate_to: localhost
|
|
||||||
raw: "lxc exec {{ inventory_hostname }} -- rc-update add dropbear"
|
|
||||||
|
|
||||||
- name: enable dropbear
|
|
||||||
connection: local
|
|
||||||
delegate_to: localhost
|
|
||||||
raw: "lxc exec {{ inventory_hostname }} -- rc-service dropbear restart"
|
|
||||||
|
|
||||||
- name: install software
|
|
||||||
package: name={{ install_software }} state=present update_cache=yes
|
|
||||||
|
|
||||||
- name: deploy motd
|
- name: deploy motd
|
||||||
copy:
|
copy:
|
||||||
src: motd
|
src: motd
|
||||||
dest: /etc/motd
|
dest: /etc/motd
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
|
||||||
- name: deploy syslog config
|
|
||||||
copy:
|
|
||||||
src: syslog.conf
|
|
||||||
dest: /etc/conf.d/syslog
|
|
||||||
mode: 0644
|
|
||||||
notify:
|
|
||||||
- restart container
|
|
||||||
|
|
||||||
- name: deploy update script
|
|
||||||
copy:
|
|
||||||
src: update.sh
|
|
||||||
dest: /etc/periodic/daily/update
|
|
||||||
mode: 0755
|
|
||||||
|
21
tasks/rockylinux.yml
Normal file
21
tasks/rockylinux.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- name: install basics
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- yum install -y python3 wget openssh-server"
|
||||||
|
|
||||||
|
- name: setup ssh
|
||||||
|
include: ssh.yml
|
||||||
|
|
||||||
|
- name: enable dropbear
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- systemctl enable sshd"
|
||||||
|
|
||||||
|
- name: enable dropbear
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- systemctl restart sshd"
|
||||||
|
|
||||||
|
- name: install software
|
||||||
|
package: name={{ rockylinux_software }} state=present update_cache=yes
|
15
tasks/ssh.yml
Normal file
15
tasks/ssh.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
- name: mkdir ~/.ssh
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- mkdir -p /root/.ssh"
|
||||||
|
|
||||||
|
- name: get authorized_keys
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- wget -O /root/.ssh/authorized_keys https://git.br0tkasten.de/br0tkasten/configs/raw/branch/master/dotfiles/authorized_keys"
|
||||||
|
|
||||||
|
- name: fix file permissions
|
||||||
|
connection: local
|
||||||
|
delegate_to: localhost
|
||||||
|
raw: "lxc exec {{ inventory_hostname }} -- chmod 0600 /root/.ssh/authorized_keys"
|
2
templates/aliases.j2
Normal file
2
templates/aliases.j2
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
root: {{ mailto }}
|
||||||
|
default: {{ mailto }}
|
11
templates/msmtprc.j2
Normal file
11
templates/msmtprc.j2
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
defaults
|
||||||
|
syslog on
|
||||||
|
set_from_header on
|
||||||
|
aliases /etc/aliases
|
||||||
|
|
||||||
|
account {{ inventory_hostname_short }}
|
||||||
|
host {{ mailrelay }}
|
||||||
|
from {{ inventory_hostname_short }}@br0tkasten.de
|
||||||
|
port {{ mailport }}
|
||||||
|
|
||||||
|
account default : {{ inventory_hostname_short }}
|
@ -1,9 +1,21 @@
|
|||||||
---
|
---
|
||||||
install_software:
|
alpine_software:
|
||||||
- git
|
- git
|
||||||
- bash
|
- bash
|
||||||
- dropbear
|
- dropbear
|
||||||
- python3
|
- python3
|
||||||
# - openssh-server # enable when needed for scp
|
|
||||||
- openssh-client-default
|
- openssh-client-default
|
||||||
- openssh-client-common
|
- openssh-client-common
|
||||||
|
- msmtp
|
||||||
|
- mailx
|
||||||
|
|
||||||
|
archlinux_software:
|
||||||
|
- git
|
||||||
|
- bash
|
||||||
|
- dropbear
|
||||||
|
|
||||||
|
rockylinux_software:
|
||||||
|
- git
|
||||||
|
- bash
|
||||||
|
- openssh-server
|
||||||
|
- python3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user