imfreedom/email-ansible

Add statping
draft
2021-05-06, Gary Kramlich
3d873fd228ef
Parents 68119a848120
Children 737268985cb9
Add statping
--- a/inventories/pidgin/hosts.yaml Thu Nov 26 01:23:44 2020 -0600
+++ b/inventories/pidgin/hosts.yaml Thu May 06 06:39:31 2021 -0500
@@ -4,5 +4,9 @@
hosts:
dodo.pidgin.im:
ansible_user: root
+ statping_servers:
+ hosts:
+ dodo.pidgin.im:
+ ansible_users: root
vars:
ansible_python_interpreter: /usr/bin/python3
--- a/inventories/pidgin/vault.yaml Thu Nov 26 01:23:44 2020 -0600
+++ b/inventories/pidgin/vault.yaml Thu May 06 06:39:31 2021 -0500
@@ -1,66 +1,71 @@
$ANSIBLE_VAULT;1.1;AES256
-63663534306133656534616130383362646231363139626438653765356537336138386533326535
-3862333231323639396630616363653063653962633131320a306438396138393063316631306161
-30356633396230383162393633626163316534393334333564336661343331656338663361373930
-6533333437346330370a613037383632336432313432623139323766613638653561316363393530
-36323238663532346636666261653735376633626366646336393734656235646463616138366639
-62613536656639333733653066656136303334343738383963633538363130636334393833666234
-35623433616361633833353862653361366537626361303262386336623162316464623231346561
-36656539383561396235393862383332636230346533353739343164333832623363316263623432
-66643964326630306237623335343666323734663164663439343935323863626530303133326631
-35356639323236663833643436616630363465306635336163633064333533326164303766663235
-35653961323235353035353863626466643363623930393433323234363535306164616635626161
-36653264303463323538303432616562353933343637316436656233386338623765353337656530
-63613234633134646364303161646138333662356439303264303963656165353532613564376661
-31393766366463626538313739663838623761333733383565373334363637616462326266393638
-34663462373566376332663038636139613266663737646161323362373462363536303931373961
-37663766356132613838373662633963393033666264363164663763363331313438666433373966
-30306566346564626630303965663466393963363237623665653433313862333165346330656364
-35613339393337353361353037643832663132363239303636336163363461623736353134663062
-66353632363266613761663238316465633536353363303763643666613364353238353030306464
-35323430366430393464633836613430626362373634326432376262646537366536636531626264
-37346138656166343336306538343032623030643632656164326631643238383565626363326634
-32643132616132396361613138323633633861643037376535616131366435313064386332666133
-33613733386537613338363434363332373162653239346466663737333437326131393461633065
-30316361643831373666383030626466396336336436626263343463323734353133623137613335
-64336665616531313434336332326534336366663134356665376564356131623234393832613739
-39323166303739353061653664343635616662393664656631336630643138363166633430363661
-33626239616231353464353765623333633839346263643865313632393238656139373366396136
-61336464373234356633646165633162336638623161623031613664323934303132613839366661
-65613235613466346163666232663635643564343133663130346239313938323461646464623562
-39346536663832666366633566396164616138663935656365316663363531626330393131356630
-66613033636463343465653662306161323930366631663764616161626565383135653633343433
-35383635353438636664643665633439316266313262393062393238363838363632303363653337
-66396538316337396636666463356439303266333633633833363333646634326462396637303231
-66303237613933656239383133366634646166316137666161633763333032633132643665663231
-35336332373965313332356365376633663362343534373231356639626361613362316234363337
-35393133373735626563653266623534366132373730356535333232656332343631356533653166
-32663238396631666437626632356439393434373035633531383136663161336166363335623262
-37303137363339363061336333376163663133626462653265633432656561343866323638356536
-31373734303238666663376566646430356532633363326330646430336362353561623866653135
-65353262666235333731336431643066363366336538643734373030313239613531313139636465
-37383236386262306334626266363931633835656633383630353632313735303533333330386432
-64313164373635643561666364653539336631636462643362623963653239323165633162663736
-38383733303065316332313564643532313362663964313539636332643533363861653035643330
-66623139356561623033383032636631326364316635376539343234616261626639353562393164
-33623261393639613036393562376137636534313837633137663463323665333431626631626264
-62323638623134626666643735333265316666356337386466663666636232343265656530336133
-66346435396364376533633464613534343135343638333466326230313331626130343331353365
-31333638363433393262323139343035383132666437336232343031613130636339303964313636
-30636563396565633232316532336566613231316138663364393835306366653561666361663166
-64643236633530353134396561633830653834323133376236656336326630353966383661663432
-34646262303836393664376230326537643461306264336265306234326463393134313232656362
-37336461353339373763346435393032376366393335663764663961663063323364336531343130
-62346634383935346262373463373639313631623763633330613666356631393761306638356461
-39653661343531663933303865646633373766376164383865633333306166343837663963396634
-39343434646432653930356365633930353732306363323230626662393565646533383431616431
-31656463373637353635646362326138306531353433303664393539646134383664316437383932
-37353035343438633961353965646134303832616333626333373666333330313631396337333232
-64323638616539363938363530636265363836633365313762626137663138336433623864623439
-38646530383135633933653435303831343733636561666661366134313832346430313961626264
-31636634346131306639326366663865376561353030616132656432323462336334356133663135
-30313937336665333136393066363435626139643236326637376434393832626637373036613262
-65326463353537666537386135613763353335393264353866653536316562646166643332386664
-66653862383864623466326230313963636566353166363639323164363032343761653138656637
-37646138303337646337363864373733666331613631386134663961626262616530643438316134
-3566
+39383264373932313933623236643463663239613134636632343438326132383431646330633065
+3737393364616435323734393132353261316438646565650a343866363039613237663235336533
+35356539366133643064353035623063313433383565393264376430306135633966616364613362
+6365643734363238620a323933363763653538393665316635653730646337353265373833643864
+39373739343438353062663864646365363564656139346238353465393638633731373064306332
+33396666656530373531663734623263383932653230643730383462643831356630363763646632
+35633265636135653137373763303632313761633938396166626165626530633330643736656131
+33656263313661633630636136363136306234383334376633353962336666396537626630303331
+64336165623933303539343533663737626232363863343237623139663735663963633537376632
+63323961336636376664643239373831376263633439343433306661356133356339353431303730
+65383637326264633235613061636434313135316464366363306664613730316538623864306638
+34656634383533626231623031353230653965303361333834656134356637313037663331356432
+34316162313637323130656365663162376261326534366631363331333733323363623330383132
+34306137343130323539386133636332663937396165336139626162643636343033323266623462
+61303262633239303036643665643137393130396664343730366436663665346664663130633437
+31343330383165643231313538393763616234643764303064363765386565386133646366353462
+63666562346362333630383237343334353066303762313235613563303965616166373033316634
+66383136393166643932663664626164653066666433653761646435393164376635623630343966
+35366536346564636632633835653163346162343963383765366163646466326630613861393464
+37383532333637386633666430356134343861363833363062376638643339396363663836623462
+31623037613161626132656233366432336438393035623734663662373161346535613533326562
+30343434313964383131386261363934666566653136633739633639636134393736343039643333
+62333030623531336233333531363339316532633134386530313033363838396166383166373430
+66383533333635306430363632663933306138313362346132363235386436323936376137323766
+61656561393961393732353239656666306234373636306534363563333336313730626338316332
+35306633333162366361356238326466376430646563326130373461636239356638646535373463
+34376466306538393635383831633732396462383930316134626462343331333030363433306162
+61386661633663346464633137393865643937356263353134343865323632646464303231346362
+62663362393565353035356331363965376133393264323638373337656638313364316337643235
+61623561366232613832353032613661303031363764306631656161366532336138366237333335
+37346638306231626463316564353462353333306337633239373863353638633461386631363763
+31623361383961313135323639303535393563393434373465616536653434373265636465616535
+38393835613763313637386230373937306235643038366635653932343266333461616563356165
+34363665376264366235376465313138363662616664303930336161316261363033323230333336
+63373466633932386532306336393865646435326664376261636431373963316333396530626430
+31633739333362613266363535396662383365356233313835643234343366316461643830313162
+35616366303166653563336538326366373738343732383631313734316432366262313336323833
+33373136316466326535393932343730623835646664346265393663343833323464343465643136
+34623132303530343766376163366466306462333033346462343337336666616165663730383639
+64303638346138646336393931316634363638623131356432343335653137303939643133663539
+62623431353763363266303531613633626364643332333366636163376163386663356432326532
+65613361333563313263313538653637333365623831353265323839633461326664623838383530
+63373138386136613739643865363166336636363331383631323535383038373339343964313131
+61313365353664613363643137623134643534313063303031313737636135346464653363633036
+65343965396633666662653661366536363535363834626137333861623733323238646464343035
+34656536356265336263623535316337326165383738333632303464343038333133313463623463
+64393430343061336163623536623862346232656537623737333839333734646138386230343639
+36663961666162306433393538396332643831636161313130623237656464316131636263303763
+37346565333261626231323265653439356462356665373631656133623662313436313064623761
+62353139626434393732343535656132326266623161333466623662646163326435656562363763
+64613137393931343132363631363138613234306465366237643766623537626466333237613532
+39323965383033376332346236326261663636636330643936383865616237636139623434313135
+63623064313431373833393538393461346338333532393137343834623965656132373431313261
+66613830346564653164386238376162646538653232316435316535333431653065666265623836
+65353661623830356332396232336333346639316231316138363466626535393265316137326532
+39313633623262316332396465376537386538633163376566306336363863356663626139333131
+38356138396332316266366531346561303138636132643461623662623365313435666662636238
+33313231396635373834643266393466666538653537623035656435336334373431313061623632
+65613733646364626136393662373936343563316266306135353361383436623731356631373835
+64356336616538323633326266633565333032633736653039306564656565333961653662323035
+36366363613735303433306164353936313731626130353364356665663265393534616536613736
+35353262386262376561373932353764356537353164616533373566616262336663636233373532
+32313736353532626233393233626262346364383863666666616165343861636233623233363733
+33393663353234376361346232346237643439623337303665366361623939356534323338653134
+33616564353738303964313331636635363832336362316539326366343965633861386636656635
+63353964323239363737313834313433383938373532343165656138636562386634326564663633
+36343262623230383233386334646465633266396636613639636262636339323930633834333639
+65656434313130666236663064363937363531636561353862393833666637346637336330616462
+61663434396632336236643133323964326365303766346361636334303666343734346637666463
+3562393235626330323364646664343365383438303639333934
--- a/roles/mail/tasks/software.yaml Thu Nov 26 01:23:44 2020 -0600
+++ b/roles/mail/tasks/software.yaml Thu May 06 06:39:31 2021 -0500
@@ -6,6 +6,7 @@
force_apt_get: yes
vars:
mail_packages:
+ - dovecot-auth-lua
- dovecot-core
- dovecot-imapd
- dovecot-lmtpd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/postgresql/tasks/main.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,8 @@
+---
+- include_tasks: "software.yaml"
+ args:
+ apply:
+ tags:
+ - "postgresql"
+ tags:
+ - "always"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/postgresql/tasks/software.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,10 @@
+- name: "install software"
+ apt:
+ name: "{{ postgresql_packages }}"
+ state: "present"
+ cache_valid_time: "3600"
+ force_apt_get: "yes"
+ vars:
+ postgresql_packages:
+ - "postgresql"
+ - "python3-psycopg2"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/defaults/main.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,14 @@
+---
+statping_version: "v0.90.74"
+statping_os: "linux"
+statping_arch: "amd64"
+statping_checksum: "sha256:d287782dde1b96afbc7e41a95568347dddc0967db114feede1492cfe1fc6f3c3"
+statping_user: "statping"
+statping_group: "statping"
+statping_home: "/var/lib/statping"
+statping_port: "9000"
+statping_address: "localhost"
+statping_postgresql_host: "localhost"
+statping_postgresql_port: "5432"
+statping_postgresql_database: "statping"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/handlers/main.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,13 @@
+---
+- name: "reload systemd"
+ systemd:
+ daemon_reload: "yes"
+- name: "restart statping"
+ systemd:
+ name: "statping"
+ state: "restarted"
+- name: "reload apache2"
+ systemd:
+ name: "apache2"
+ state: "reloaded"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/meta/main.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,5 @@
+---
+dependencies:
+ - "apache2"
+ - "postgresql"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/tasks/apache2.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,46 @@
+---
+- name: "enable modules"
+ community.general.apache2_module:
+ state: "present"
+ name: "{{ item }}"
+ loop:
+ - "proxy"
+ - "proxy_http"
+ notify:
+ - "reload apache2"
+ tags:
+ - "apache"
+- name: "obtain certificates"
+ command: |
+ certbot --quiet -m root@pidgin.im --no-eff-email --agree-tos
+ --webroot -w /var/www/html/ certonly
+ -d {{ item }}
+ args:
+ creates: "/etc/letsencrypt/live/{{ item }}/cert.pem"
+ loop:
+ - "status.pidgin.im"
+ - "status.imfreedom.org"
+ notify:
+ - "reload apache2"
+ tags:
+ - "apache"
+ - "certbot"
+- name: "install apache configuration"
+ template:
+ src: "{{ item }}.conf.j2"
+ dest: "/etc/apache2/sites-available/{{ item }}.conf"
+ mode: "0644"
+ loop:
+ - "status.pidgin.im"
+ - "status.imfreedom.org"
+ tags:
+ - "apache"
+- name: "enable apache configuration"
+ command: "a2ensite {{ item }}"
+ loop:
+ - "status.pidgin.im"
+ - "status.imfreedom.org"
+ notify:
+ - "reload apache2"
+ tags:
+ - "apache"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/tasks/config.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,18 @@
+---
+- name: "create runtime directory"
+ file:
+ path: "{{ statping_home }}/statping"
+ state: "directory"
+ mode: "0700"
+ owner: "{{ statping_user }}"
+ group: "{{ statping_group }}"
+- name: "install config"
+ template:
+ src: "config.yml.j2"
+ dest: "{{ statping_home }}/statping/config.yml"
+ mode: "0600"
+ owner: "{{ statping_user }}"
+ group: "{{ statping_group }}"
+ notify:
+ - "restart statping"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/tasks/database.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,21 @@
+---
+- name: "create database"
+ community.postgresql.postgresql_db:
+ name: "{{ statping_postgresql_database }}"
+ become_user: "postgres"
+ become: "yes"
+- name: "create role"
+ community.postgresql.postgresql_user:
+ db: "{{ statping_postgresql_database }}"
+ name: "{{ statping_postgresql_username }}"
+ password: "{{ statping_postgresql_password }}"
+ become_user: "postgres"
+ become: "yes"
+- name: "grant access"
+ community.postgresql.postgresql_owner:
+ db: "{{ statping_postgresql_database }}"
+ new_owner: "{{ statping_postgresql_username }}"
+ obj_name: "{{ statping_postgresql_database }}"
+ obj_type: "database"
+ become_user: "postgres"
+ become: "yes"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/tasks/main.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,44 @@
+- include_tasks: "user.yaml"
+ args:
+ apply:
+ tags:
+ - "statping"
+ tags:
+ - "always"
+- include_tasks: "software.yaml"
+ args:
+ apply:
+ tags:
+ - "statping"
+ tags:
+ - "always"
+- include_tasks: "database.yaml"
+ args:
+ apply:
+ tags:
+ - "statping"
+ tags:
+ - "always"
+- include_tasks: "systemd.yaml"
+ when: ansible_system == "Linux"
+ args:
+ apply:
+ tags:
+ - "statping"
+ tags:
+ - "always"
+- include_tasks: "config.yaml"
+ args:
+ apply:
+ tags:
+ - "statping"
+ tags:
+ - "always"
+- include_tasks: "apache2.yaml"
+ args:
+ apply:
+ tags:
+ - "statping"
+ tags:
+ - "always"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/tasks/software.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,18 @@
+---
+- name: "build filename"
+ set_fact:
+ statping_filename: "statping-{{statping_os}}-{{statping_arch}}.tar.gz"
+- name: "build url"
+ set_fact:
+ statping_download_url: "https://github.com/statping/statping/releases/download/{{statping_version}}/{{statping_filename}}"
+- name: "download"
+ get_url:
+ url: "{{statping_download_url}}"
+ checksum: "{{statping_checksum}}"
+ dest: "{{statping_home}}/{{statping_filename}}"
+- name: "extract"
+ unarchive:
+ remote_src: "yes"
+ src: "{{statping_home}}/{{statping_filename}}"
+ dest: "/usr/local/bin/"
+ mode: "0755"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/tasks/systemd.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,12 @@
+---
+- name: install systemd unit
+ template:
+ src: "statping.service.j2"
+ dest: "/etc/systemd/system/statping.service"
+ mode: "0640"
+ notify:
+ - "reload systemd"
+- name: start systemd service
+ systemd:
+ name: "statping"
+ state: "restarted"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/tasks/user.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,13 @@
+---
+- name: "create group {{statping_group}}"
+ group:
+ name: "{{statping_group}}"
+ system: "yes"
+- name: "create user {{statping_user}}"
+ user:
+ name: "{{statping_user}}"
+ shell: "/bin/false"
+ group: "{{statping_group}}"
+ system: "yes"
+ createhome: "yes"
+ home: "{{statping_home}}"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/templates/config.yml.j2 Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,17 @@
+connection: postgres
+host: {{ statping_postgresql_host }}
+user: {{ statping_postgresql_username }}
+password: {{ statping_postgresql_password }}
+database: {{ statping_postgresql_database }}
+port: {{ statping_postgresql_port }}
+language: en
+allow_reports: false
+location: {{ statping_home }}/statping
+disable_http: false
+demo_mode: false
+disable_logs: false
+use_assets: false
+sample_data: false
+use_cdn: false
+disable_colors: false
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/templates/statping.service.j2 Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,18 @@
+[Unit]
+Description=Statping Server
+After=network.target
+After=systemd-user-sessions.service
+After=network-online.target
+
+[Service]
+Type=simple
+Restart=always
+User={{statping_user}}
+Group={{statping_group}}
+Environment=STATPING_DIR={{ statping_home }}/statping
+ExecStart=/usr/local/bin/statping -v 1 --config {{ statping_home }}/statping/config.yml --ip {{ statping_address }} --port {{ statping_port }}
+WorkingDirectory=/usr/local/bin
+
+[Install]
+WantedBy=multi-user.target
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/templates/status.imfreedom.org.conf.j2 Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,40 @@
+<VirtualHost *:80>
+ ServerName status.imfreedom.org
+ ServerAdmin root@imfreedom.org
+ DocumentRoot /var/www/html
+
+ <Directory /var/www/html>
+ AllowOverride None
+ Require all granted
+
+ Options +FollowSymLinks
+
+ RewriteEngine On
+ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*$ [NC]
+ RewriteRule ^(.*)$ https://status.pidgin.im/ [R=301]
+ </Directory>
+</VirtualHost>
+
+<VirtualHost *:443>
+ ServerName status.imfreedom.org
+ ServerAdmin root@imfreedom.org
+ DocumentRoot /var/www/html
+
+ SSLEngine on
+ SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
+ SSLCertificateKeyFile /etc/letsencrypt/live/status.imfreedom.org/privkey.pem
+ SSLCACertificateFile /etc/letsencrypt/live/status.imfreedom.org/chain.pem
+ SSLCertificateFile /etc/letsencrypt/live/status.imfreedom.org/cert.pem
+
+ <Directory /var/www/html>
+ AllowOverride None
+ Require all granted
+
+ Options +FollowSymLinks
+
+ RewriteEngine On
+ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*$ [NC]
+ RewriteRule ^(.*)$ https://status.pidgin.im/ [R=301]
+ </Directory>
+</VirtualHost>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/statping/templates/status.pidgin.im.conf.j2 Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,32 @@
+<VirtualHost *:80>
+ ServerName status.pidgin.im
+ ServerAdmin root@pidgin.im
+ DocumentRoot /var/www/html
+
+ <Directory /var/www/html>
+ AllowOverride None
+ Require all granted
+
+ Options +FollowSymLinks
+
+ RewriteEngine On
+ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*$ [NC]
+ RewriteRule ^(.*)$ https://status.pidgin.im/ [R=301]
+ </Directory>
+</VirtualHost>
+
+<VirtualHost *:443>
+ ServerName status.pidgin.im
+ ServerAdmin root@pidgin.im
+ DocumentRoot /var/www/html
+
+ SSLEngine on
+ SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
+ SSLCertificateKeyFile /etc/letsencrypt/live/status.pidgin.im/privkey.pem
+ SSLCACertificateFile /etc/letsencrypt/live/status.pidgin.im/chain.pem
+ SSLCertificateFile /etc/letsencrypt/live/status.pidgin.im/cert.pem
+
+ ProxyPass / http://{{ statping_address }}:{{ statping_port }}/
+ ProxyPassReverse / http://{{ statping_address}}:{{ statping_port}}/
+</VirtualHost>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/statping_servers.yaml Thu May 06 06:39:31 2021 -0500
@@ -0,0 +1,4 @@
+- hosts: statping_servers
+ roles:
+ - statping
+