mirror of
https://github.com/mdlayher/homelab.git
synced 2024-12-14 11:47:32 +00:00
*: move to typical ansible structure, add servnerr role in test environment
This commit is contained in:
parent
70cd302c47
commit
1d94369641
17 changed files with 183 additions and 173 deletions
|
@ -1,43 +0,0 @@
|
|||
---
|
||||
- hosts: golang
|
||||
vars:
|
||||
# Personal Go configuration
|
||||
- golang_user: "root"
|
||||
- golang_home_dir: "/root"
|
||||
- golang_personal_gopath: "github.com/mdlayher"
|
||||
# Go installation configuration
|
||||
- golang_url: "https://storage.googleapis.com/golang/go1.6.1.linux-amd64.tar.gz"
|
||||
- golang_tgz: "/tmp/golang.tar.gz"
|
||||
- golang_sha256: "6d894da8b4ad3f7f6c295db0d73ccc3646bce630e1c43e662a0120681d47e988"
|
||||
- golang_root: "/usr/local/go"
|
||||
tasks:
|
||||
- name: install git
|
||||
apt: pkg=git state=installed
|
||||
|
||||
- name: install mercurial
|
||||
apt: pkg=mercurial state=installed
|
||||
|
||||
- name: download and checksum go tarball
|
||||
get_url: url={{ golang_url }} dest={{ golang_tgz }} checksum=sha256:{{ golang_sha256 }}
|
||||
|
||||
- name: unpack tarball
|
||||
unarchive: src={{ golang_tgz }} dest=/usr/local/ copy=no
|
||||
|
||||
- name: insert go configuration into shell configuration
|
||||
blockinfile:
|
||||
dest: /{{ golang_user }}/.bashrc
|
||||
marker: "# {mark} ansible-managed Go configuration"
|
||||
block: |
|
||||
export GOROOT={{ golang_root }}
|
||||
export GOROOT_BOOTSTRAP=$GOROOT
|
||||
export GOPATH=$HOME
|
||||
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
||||
|
||||
- name: create personal GOPATH location
|
||||
file: path={{ golang_home_dir }}/src/{{ golang_personal_gopath }} state=directory
|
||||
|
||||
- name: symlink personal GOPATH location to ~/go
|
||||
file: dest={{ golang_home_dir }}/go src={{ golang_home_dir }}/src/{{ golang_personal_gopath }} owner={{ golang_user }} group={{ golang_user }} state=link
|
||||
|
||||
- name: remove temporary go tarball
|
||||
file: path={{ golang_tgz }} state=absent
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
- hosts: plex
|
||||
vars:
|
||||
- plex_url: "https://downloads.plex.tv/plex-media-server/0.9.16.4.1911-ee6e505/plexmediaserver_0.9.16.4.1911-ee6e505_amd64.deb"
|
||||
- plex_deb: "/tmp/plex.deb"
|
||||
- plex_sha1: "c056838454953857fec2622ddd7350635723c09e"
|
||||
tasks:
|
||||
- name: download and checksum plex debian package
|
||||
get_url: url={{ plex_url }} dest={{ plex_deb }} checksum=sha1:{{ plex_sha1 }}
|
||||
|
||||
- name: install plex
|
||||
apt: deb={{ plex_deb }} state=installed
|
||||
|
||||
- name: remove temporary plex debian package
|
||||
file: path={{ plex_deb }} state=absent
|
||||
|
||||
- name: start plex service
|
||||
service: name=plexmediaserver state=started enabled=yes
|
|
@ -1,75 +0,0 @@
|
|||
---
|
||||
- hosts: prometheus
|
||||
vars:
|
||||
# Prometheus version and checksum configuration
|
||||
- prometheus_version: "0.18.0rc1"
|
||||
- prometheus_sha1: "915b0396b9ed973842c3c3e5394caec24269fa37"
|
||||
# Prometheus configuration and data storage locations
|
||||
- prometheus_config: "/etc/prometheus/prometheus.yml"
|
||||
- prometheus_data: "/var/lib/prometheus/"
|
||||
# Prometheus jobs configuration
|
||||
- prometheus_jobs:
|
||||
- job: "edgemax"
|
||||
targets:
|
||||
- "192.168.1.3:9132"
|
||||
- job: "node"
|
||||
targets:
|
||||
- "192.168.1.3:9100"
|
||||
- "192.168.1.5:9100"
|
||||
- "192.168.1.20:9100"
|
||||
- job: "prometheus"
|
||||
scrape_interval: "5s"
|
||||
targets:
|
||||
- "192.168.1.3:9090"
|
||||
- job: "rtorrent"
|
||||
scrape_interval: "5s"
|
||||
targets:
|
||||
- "192.168.1.3:9135"
|
||||
- job: "unifi"
|
||||
targets:
|
||||
- "unifi.servnerr.com:9130"
|
||||
- job: "zfs"
|
||||
targets:
|
||||
- "192.168.1.3:9134"
|
||||
# Static configuration.
|
||||
- prometheus_dir: "prometheus-{{ prometheus_version }}.linux-amd64"
|
||||
- prometheus_tmp: "/tmp/{{ prometheus_dir }}"
|
||||
- prometheus_url: "https://github.com/prometheus/prometheus/releases/download/{{ prometheus_version }}/{{ prometheus_dir }}.tar.gz"
|
||||
- prometheus_tgz: "/tmp/prometheus.tar.gz"
|
||||
tasks:
|
||||
- name: stop prometheus service
|
||||
service: name=prometheus state=stopped
|
||||
|
||||
- name: download and checksum prometheus tarball
|
||||
get_url: url={{ prometheus_url }} dest={{ prometheus_tgz }} checksum=sha1:{{ prometheus_sha1 }}
|
||||
|
||||
- name: unpack tarball
|
||||
unarchive: src={{ prometheus_tgz }} dest=/tmp/ copy=no
|
||||
|
||||
- name: create prometheus user
|
||||
user: name=prometheus shell=/bin/false comment="prometheus service user"
|
||||
|
||||
- name: copy prometheus binary to /usr/local/bin
|
||||
copy: src={{ prometheus_tmp }}/prometheus dest=/usr/local/bin/ owner=prometheus group=prometheus mode=0755
|
||||
|
||||
- name: copy promtool binary to /usr/local/bin
|
||||
copy: src={{ prometheus_tmp }}/promtool dest=/usr/local/bin/ owner=prometheus group=prometheus mode=0755
|
||||
|
||||
- name: create prometheus configuration
|
||||
template: src=templates/prometheus.yml.j2 dest={{ prometheus_config }}
|
||||
with_items: "{{ prometheus_jobs }}"
|
||||
|
||||
- name: create prometheus data directory
|
||||
file: path={{ prometheus_data }} state=directory owner=prometheus group=prometheus mode=0755
|
||||
|
||||
- name: create prometheus upstart job
|
||||
template: src=templates/prometheus.conf.j2 dest=/etc/init/prometheus.conf
|
||||
|
||||
- name: start prometheus service
|
||||
service: name=prometheus state=started enabled=yes
|
||||
|
||||
- name: remove temporary prometheus directory
|
||||
file: path={{ prometheus_tmp }} state=absent
|
||||
|
||||
- name: remove temporary prometheus tarball
|
||||
file: path={{ prometheus_tgz }} state=absent
|
|
@ -1,36 +0,0 @@
|
|||
---
|
||||
- hosts: rtorrent
|
||||
vars:
|
||||
# Client configurations
|
||||
- rtorrent_port: 58575
|
||||
- rtorrent_download_rate: 10000
|
||||
- rtorrent_upload_rate: 400
|
||||
- rtorrent_low_diskspace: "1G"
|
||||
# Path configurations
|
||||
- rtorrent_path_root: "/mnt/rtorrent"
|
||||
- rtorrent_path_files: "{{ rtorrent_path_root }}/files"
|
||||
- rtorrent_path_session: "{{ rtorrent_path_root }}/.session"
|
||||
- rtorrent_path_watch: "{{ rtorrent_path_root }}/watch"
|
||||
tasks:
|
||||
- name: install rtorrent
|
||||
apt: pkg=rtorrent state=installed
|
||||
register: rtorrentinstalled
|
||||
|
||||
- name: fail the play if rtorrent could not be installed
|
||||
when: rtorrentinstalled|failed
|
||||
fail: msg="failed to install rtorrent"
|
||||
|
||||
- name: create rtorrent user
|
||||
user: name=rtorrent shell=/bin/false comment="rtorrent service user"
|
||||
|
||||
- name: create rtorrent configuration
|
||||
template: src=rtorrent.rc.j2 dest=/home/rtorrent/.rtorrent.rc owner=rtorrent group=rtorrent mode=0755
|
||||
|
||||
- name: create files directory
|
||||
file: path={{ rtorrent_path_files }} state=directory owner=rtorrent group=rtorrent mode=0755
|
||||
|
||||
- name: create watch directory
|
||||
file: path={{ rtorrent_path_watch }} state=directory owner=rtorrent group=rtorrent mode=0755
|
||||
|
||||
- name: create session directory
|
||||
file: path={{ rtorrent_path_session }} state=directory owner=rtorrent group=rtorrent mode=0755
|
31
roles/golang/tasks/main.yml
Normal file
31
roles/golang/tasks/main.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
- name: install git
|
||||
apt: pkg=git state=installed
|
||||
|
||||
- name: install mercurial
|
||||
apt: pkg=mercurial state=installed
|
||||
|
||||
- name: download and checksum go tarball
|
||||
get_url: url={{ golang_url }} dest={{ golang_tgz }} checksum=sha256:{{ golang_sha256 }}
|
||||
|
||||
- name: unpack tarball
|
||||
unarchive: src={{ golang_tgz }} dest=/usr/local/ copy=no
|
||||
|
||||
- name: insert go configuration into shell configuration
|
||||
blockinfile:
|
||||
dest: /{{ golang_user }}/.bashrc
|
||||
marker: "# {mark} ansible-managed Go configuration"
|
||||
block: |
|
||||
export GOROOT={{ golang_root }}
|
||||
export GOROOT_BOOTSTRAP=$GOROOT
|
||||
export GOPATH=$HOME
|
||||
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
||||
|
||||
- name: create personal GOPATH location
|
||||
file: path={{ golang_home_dir }}/src/{{ golang_personal_gopath }} state=directory
|
||||
|
||||
- name: symlink personal GOPATH location to ~/go
|
||||
file: dest={{ golang_home_dir }}/go src={{ golang_home_dir }}/src/{{ golang_personal_gopath }} owner={{ golang_user }} group={{ golang_user }} state=link
|
||||
|
||||
- name: remove temporary go tarball
|
||||
file: path={{ golang_tgz }} state=absent
|
10
roles/golang/vars/main.yml
Normal file
10
roles/golang/vars/main.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
# Personal Go configuration
|
||||
golang_user: "root"
|
||||
golang_home_dir: "/root"
|
||||
golang_personal_gopath: "github.com/mdlayher"
|
||||
# Go installation configuration
|
||||
golang_url: "https://storage.googleapis.com/golang/go1.6.1.linux-amd64.tar.gz"
|
||||
golang_tgz: "/tmp/golang.tar.gz"
|
||||
golang_sha256: "6d894da8b4ad3f7f6c295db0d73ccc3646bce630e1c43e662a0120681d47e988"
|
||||
golang_root: "/usr/local/go"
|
12
roles/plex/tasks/main.yml
Normal file
12
roles/plex/tasks/main.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
- name: download and checksum plex debian package
|
||||
get_url: url={{ plex_url }} dest={{ plex_deb }} checksum=sha1:{{ plex_sha1 }}
|
||||
|
||||
- name: install plex
|
||||
apt: deb={{ plex_deb }} state=installed
|
||||
|
||||
- name: remove temporary plex debian package
|
||||
file: path={{ plex_deb }} state=absent
|
||||
|
||||
- name: start plex service
|
||||
service: name=plexmediaserver state=started enabled=yes
|
4
roles/plex/vars/main.yml
Normal file
4
roles/plex/vars/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
plex_url: "https://downloads.plex.tv/plex-media-server/0.9.16.4.1911-ee6e505/plexmediaserver_0.9.16.4.1911-ee6e505_amd64.deb"
|
||||
plex_deb: "/tmp/plex.deb"
|
||||
plex_sha1: "c056838454953857fec2622ddd7350635723c09e"
|
45
roles/prometheus/tasks/main.yml
Normal file
45
roles/prometheus/tasks/main.yml
Normal file
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
- name: check if prometheus service exists
|
||||
stat: path=/etc/init/prometheus.conf
|
||||
register: prometheusexists
|
||||
|
||||
- name: stop prometheus service
|
||||
service: name=prometheus state=stopped
|
||||
when: prometheusexists.stat.exists
|
||||
|
||||
- name: download and checksum prometheus tarball
|
||||
get_url: url={{ prometheus_url }} dest={{ prometheus_tgz }} checksum=sha1:{{ prometheus_sha1 }}
|
||||
|
||||
- name: unpack tarball
|
||||
unarchive: src={{ prometheus_tgz }} dest=/tmp/ copy=no
|
||||
|
||||
- name: create prometheus user
|
||||
user: name=prometheus shell=/bin/false comment="prometheus service user"
|
||||
|
||||
- name: copy prometheus binary to /usr/local/bin
|
||||
copy: src={{ prometheus_tmp }}/prometheus dest=/usr/local/bin/ owner=prometheus group=prometheus mode=0755
|
||||
|
||||
- name: copy promtool binary to /usr/local/bin
|
||||
copy: src={{ prometheus_tmp }}/promtool dest=/usr/local/bin/ owner=prometheus group=prometheus mode=0755
|
||||
|
||||
- name: create prometheus config directory
|
||||
file: path={{ prometheus_config }} state=directory owner=prometheus group=prometheus mode=0755
|
||||
|
||||
- name: create prometheus configuration
|
||||
template: src=prometheus.yml.j2 dest={{ prometheus_config }}/prometheus.yml
|
||||
with_items: "{{ prometheus_jobs }}"
|
||||
|
||||
- name: create prometheus data directory
|
||||
file: path={{ prometheus_data }} state=directory owner=prometheus group=prometheus mode=0755
|
||||
|
||||
- name: create prometheus upstart job
|
||||
template: src=prometheus.conf.j2 dest=/etc/init/prometheus.conf
|
||||
|
||||
- name: start prometheus service
|
||||
service: name=prometheus state=started enabled=yes
|
||||
|
||||
- name: remove temporary prometheus directory
|
||||
file: path={{ prometheus_tmp }} state=absent
|
||||
|
||||
- name: remove temporary prometheus tarball
|
||||
file: path={{ prometheus_tgz }} state=absent
|
|
@ -1,3 +1,4 @@
|
|||
# {{ ansible_managed }}
|
||||
# prometheus - service job file
|
||||
|
||||
description "Prometheus metrics and monitoring system"
|
||||
|
@ -17,4 +18,4 @@ setuid prometheus
|
|||
setgid prometheus
|
||||
|
||||
# What to execute
|
||||
exec /usr/local/bin/prometheus -config.file {{ prometheus_config }} -storage.local.path {{ prometheus_data }} -storage.local.chunk-encoding-version 2
|
||||
exec /usr/local/bin/prometheus -config.file {{ prometheus_config }}/prometheus.yml -storage.local.path {{ prometheus_data }} -storage.local.chunk-encoding-version 2
|
36
roles/prometheus/vars/main.yml
Normal file
36
roles/prometheus/vars/main.yml
Normal file
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
# Prometheus version and checksum configuration
|
||||
prometheus_version: "0.18.0rc1"
|
||||
prometheus_sha1: "915b0396b9ed973842c3c3e5394caec24269fa37"
|
||||
# Prometheus configuration and data storage locations
|
||||
prometheus_config: "/etc/prometheus/"
|
||||
prometheus_data: "/var/lib/prometheus/"
|
||||
# Prometheus jobs configuration
|
||||
prometheus_jobs:
|
||||
- job: "edgemax"
|
||||
targets:
|
||||
- "192.168.1.3:9132"
|
||||
- job: "node"
|
||||
targets:
|
||||
- "192.168.1.3:9100"
|
||||
- "192.168.1.5:9100"
|
||||
- "192.168.1.20:9100"
|
||||
- job: "prometheus"
|
||||
scrape_interval: "5s"
|
||||
targets:
|
||||
- "192.168.1.3:9090"
|
||||
- job: "rtorrent"
|
||||
scrape_interval: "5s"
|
||||
targets:
|
||||
- "192.168.1.3:9135"
|
||||
- job: "unifi"
|
||||
targets:
|
||||
- "unifi.servnerr.com:9130"
|
||||
- job: "zfs"
|
||||
targets:
|
||||
- "192.168.1.3:9134"
|
||||
# Static configuration.
|
||||
prometheus_dir: "prometheus-{{ prometheus_version }}.linux-amd64"
|
||||
prometheus_tmp: "/tmp/{{ prometheus_dir }}"
|
||||
prometheus_url: "https://github.com/prometheus/prometheus/releases/download/{{ prometheus_version }}/{{ prometheus_dir }}.tar.gz"
|
||||
prometheus_tgz: "/tmp/prometheus.tar.gz"
|
23
roles/rtorrent/tasks/main.yml
Normal file
23
roles/rtorrent/tasks/main.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- name: install rtorrent
|
||||
apt: pkg=rtorrent state=installed
|
||||
register: rtorrentinstalled
|
||||
|
||||
- name: fail the play if rtorrent could not be installed
|
||||
when: rtorrentinstalled|failed
|
||||
fail: msg="failed to install rtorrent"
|
||||
|
||||
- name: create rtorrent user
|
||||
user: name=rtorrent shell=/bin/false comment="rtorrent service user"
|
||||
|
||||
- name: create rtorrent configuration
|
||||
template: src=rtorrent.rc.j2 dest=/home/rtorrent/.rtorrent.rc owner=rtorrent group=rtorrent mode=0755
|
||||
|
||||
- name: create files directory
|
||||
file: path={{ rtorrent_path_files }} state=directory owner=rtorrent group=rtorrent mode=0755
|
||||
|
||||
- name: create watch directory
|
||||
file: path={{ rtorrent_path_watch }} state=directory owner=rtorrent group=rtorrent mode=0755
|
||||
|
||||
- name: create session directory
|
||||
file: path={{ rtorrent_path_session }} state=directory owner=rtorrent group=rtorrent mode=0755
|
11
roles/rtorrent/vars/main.yml
Normal file
11
roles/rtorrent/vars/main.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
# Client configurations
|
||||
rtorrent_port: 58575
|
||||
rtorrent_download_rate: 10000
|
||||
rtorrent_upload_rate: 400
|
||||
rtorrent_low_diskspace: "1G"
|
||||
# Path configurations
|
||||
rtorrent_path_root: "/mnt/rtorrent"
|
||||
rtorrent_path_files: "{{ rtorrent_path_root }}/files"
|
||||
rtorrent_path_session: "{{ rtorrent_path_root }}/.session"
|
||||
rtorrent_path_watch: "{{ rtorrent_path_root }}/watch"
|
7
servnerr.yml
Normal file
7
servnerr.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
- hosts: servnerr
|
||||
roles:
|
||||
- golang
|
||||
- plex
|
||||
- prometheus
|
||||
- rtorrent
|
2
test
Normal file
2
test
Normal file
|
@ -0,0 +1,2 @@
|
|||
[servnerr]
|
||||
test-ansible
|
Loading…
Reference in a new issue