Add common role and docker install
This commit is contained in:
parent
b1bc43e854
commit
1077a5c160
8 changed files with 141 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
[nextcloud]
|
[nextcloud]
|
||||||
nextcloud ansible_host={{INSTANCE}} ansible_user=ubuntu
|
nextcloud ansible_host={{INSTANCE}} ansible_user=ubuntu hostname=nextcloud
|
||||||
[nextcloud:vars]
|
[nextcloud:vars]
|
||||||
ansible_ssh_common_args=-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand="sh -c \"aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters portNumber=%p\""
|
ansible_ssh_common_args=-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand="sh -c \"aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters portNumber=%p\""
|
||||||
|
|
6
roles/common/handlers/main.yml
Normal file
6
roles/common/handlers/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: reboot
|
||||||
|
reboot:
|
||||||
|
reboot_timeout: 3600
|
||||||
|
|
67
roles/common/tasks/main.yaml
Normal file
67
roles/common/tasks/main.yaml
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
# configure system
|
||||||
|
|
||||||
|
- name: Configure hostname
|
||||||
|
copy:
|
||||||
|
content: "{{ hostname }}"
|
||||||
|
dest: /etc/hostname
|
||||||
|
notify: reboot
|
||||||
|
# yep we reboot for this
|
||||||
|
|
||||||
|
- name: hostname in hosts
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/hosts
|
||||||
|
regexp: "^127.0.0.1"
|
||||||
|
line: "127.0.0.1 {{ hostname }} localhost"
|
||||||
|
|
||||||
|
- name: Set timezone
|
||||||
|
file:
|
||||||
|
src: /usr/share/zoneinfo/America/Los_Angeles
|
||||||
|
dest: /etc/localtime
|
||||||
|
state: link
|
||||||
|
notify: reboot
|
||||||
|
|
||||||
|
- name: Set keyboard
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/default/keyboard
|
||||||
|
regexp: '^XKBLAYOUT='
|
||||||
|
line: 'XKBLAYOUT="us"'
|
||||||
|
notify: reboot
|
||||||
|
|
||||||
|
- name: Shaboom!!!
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
upgrade: dist
|
||||||
|
force_apt_get: yes
|
||||||
|
retries: 2
|
||||||
|
delay: 10
|
||||||
|
|
||||||
|
- name: install base apps
|
||||||
|
apt:
|
||||||
|
force_apt_get: yes
|
||||||
|
name:
|
||||||
|
- vim
|
||||||
|
- less
|
||||||
|
- tmux
|
||||||
|
- telnet
|
||||||
|
- ntp
|
||||||
|
- lsof
|
||||||
|
|
||||||
|
- name: edit bashrc
|
||||||
|
blockinfile:
|
||||||
|
path: /etc/bash.bashrc
|
||||||
|
marker: "### {mark} ANSIBLE MANAGED BLOCK {{ item.name }} ###"
|
||||||
|
block: "{{ item.block }}"
|
||||||
|
with_items:
|
||||||
|
- name: prompt
|
||||||
|
block: |
|
||||||
|
if [[ $USER == 'root' ]]; then
|
||||||
|
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]# '
|
||||||
|
else
|
||||||
|
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;36m\]\u@\h\[\033[00m\]:\[\033[01;32m\]\w\[\033[00m\]\$ '
|
||||||
|
fi
|
||||||
|
- name: lscolor
|
||||||
|
block: |
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
|
11
roles/common/templates/rpi_custom_exporter.service
Normal file
11
roles/common/templates/rpi_custom_exporter.service
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Pi4 custom collector
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/srv/rpi_custom_exporter/exporter.py
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
26
roles/common/templates/rpi_exporter.py
Normal file
26
roles/common/templates/rpi_exporter.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import time
|
||||||
|
from prometheus_client.core import GaugeMetricFamily, REGISTRY, CounterMetricFamily
|
||||||
|
from prometheus_client import start_http_server
|
||||||
|
from gpiozero import CPUTemperature
|
||||||
|
|
||||||
|
class CustomCollector(object):
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def collect(self):
|
||||||
|
val = CPUTemperature()
|
||||||
|
t = GaugeMetricFamily("rpi_cpu_temperature", "CPU Temperature", labels=['instance'])
|
||||||
|
t.add_metric(['C'], val.temperature)
|
||||||
|
yield t
|
||||||
|
|
||||||
|
f = GaugeMetricFamily("rpi_cpu_temperature_f", "CPU Temperature", labels=['instance'])
|
||||||
|
f.add_metric(['F'], val.temperature * (9.0/5.0) + 32)
|
||||||
|
yield t
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
start_http_server(7998)
|
||||||
|
REGISTRY.register(CustomCollector())
|
||||||
|
while True:
|
||||||
|
time.sleep(1)
|
2
roles/common/templates/rsyslog-rng.conf
Normal file
2
roles/common/templates/rsyslog-rng.conf
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
:programname,startswith,"rng" /dev/null
|
||||||
|
:programname,startswith,"rng" stop
|
|
@ -8,3 +8,26 @@
|
||||||
- db
|
- db
|
||||||
- data
|
- data
|
||||||
|
|
||||||
|
- name: install docker
|
||||||
|
apt:
|
||||||
|
force_apt_get: yes
|
||||||
|
name: "{{ packages }}"
|
||||||
|
vars:
|
||||||
|
packages:
|
||||||
|
- docker.io
|
||||||
|
- docker-compose
|
||||||
|
|
||||||
|
- name: Add users to docker group
|
||||||
|
user:
|
||||||
|
name: "{{ item }}"
|
||||||
|
groups: docker
|
||||||
|
append: yes
|
||||||
|
with_items:
|
||||||
|
- ubuntu
|
||||||
|
|
||||||
|
- name: do some cleanup
|
||||||
|
command: "{{item}}"
|
||||||
|
with_items:
|
||||||
|
- "docker image prune -a --force"
|
||||||
|
- "docker system prune --volumes --force"
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
#- name: get environment
|
#- name: get environment
|
||||||
# ec2_metadata_facts:
|
# ec2_metadata_facts:
|
||||||
|
|
||||||
|
- name: apply common config
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- { role: common, become: yes }
|
||||||
|
|
||||||
- name: setup nextcloud instance
|
- name: setup nextcloud instance
|
||||||
hosts: nextcloud
|
hosts: nextcloud
|
||||||
roles:
|
roles:
|
||||||
|
|
Loading…
Reference in a new issue