diff --git a/apache2.yaml b/apache2.yaml
index 28dfeff..3eeb016 100644
--- a/apache2.yaml
+++ b/apache2.yaml
@@ -1,12 +1,11 @@
---
-
- hosts: apache2
become: yes
vars:
tmpl:
- - {file: "static", value: 'Use DocRootVHost "static.rudolf" "/home/www/static"' }
- - {file: "syncthing", value: 'Use ProxySSLVHost "syncthing.rudolf" "/" "http://localhost:{{ syncthing_port }}/" "syncthing.rudolf"' }
- - {file: "jenkins", value: 'Use ProxySSLVHost "jenkins.rudolf" "/" "http://localhost:{{ jenkins_port }}/" "jenkins.rudolf"' }
+ - { file: "101-syncthing", value: 'Use ProxyHost "syncthing.rudolf" "/" "http://localhost:{{ syncthing_port }}/" "syncthing.rudolf"' }
+ - { file: "102-jenkins", value: 'Use ProxyHost "jenkins.rudolf" "/" "http://localhost:{{ jenkins_port }}/" "jenkins.rudolf"' }
+ # - {file: "static", value: 'Use DocRootVHost "static.rudolf" "/home/www/static"' }
# - {file: "torrent", value: 'Use ProxySSLVHost "torrent.rudolf" "/transmission" "http://localhost:9091/transmission" "torrent.rudolf"' }
# - {file: "", value: '# TODO Header edit Location ^http://jenkins.rudolf.com.ua https://jenkins.rudolf.com.ua' }
# - {file: "webmin", value: 'Use ProxySSLVHost "webmin.rudolf" "/" "http://localhost:10000/" "webmin.rudolf"' }
@@ -16,6 +15,9 @@
- name: install apache2
apt: name=apache2 update_cache=yes state=latest
+ - name: install libapache2-mod-auth-openidc
+ apt: name=libapache2-mod-auth-openidc state=latest
+
- name: apache2 listen on port {{ http_port }} and {{ https_port }}
lineinfile:
dest: /etc/apache2/ports.conf
@@ -28,22 +30,43 @@
notify:
- restart apache2
- - name: macro lib
- copy:
- src: apache2/macro.conf
- dest: /etc/apache2/conf-enabled/macro.conf
+ - name: populate configs
+ template:
+ src: "{{ item }}"
+ dest: /etc/apache2/conf-enabled/my-{{ item | basename }}
+ with_fileglob:
+ - apache2/conf/*.conf
+ register: apache2_configs
+ notify:
+ - restart apache2
+
+ - name: find existing files
+ find:
+ paths: /etc/apache2/conf-enabled
+ patterns: "my-*.conf"
+ register: existing_configs
+
+ - name: remove stale configs
+ file: path="{{ item }}" state=absent
+ with_items:
+ existing_configs.files|default([])|map(attribute='path')|list|
+ difference(
+ apache2_configs.results|default([])|map(attribute='path')|list
+ )|
+ list|default([])
notify:
- restart apache2
- name: enabling modules
apache2_module:
- name: "{{ item }}"
- state: present
+ name: "{{ item.name }}"
+ state: "{{ item.state }}"
with_items:
- - proxy_http
- - rewrite
- - macro
- # - ssl TODO
+ - { name: proxy_http , state: present }
+ - { name: rewrite , state: present }
+ - { name: macro , state: present }
+ - { name: auth_openidc , state: present }
+ - { name: ssl , state: absent }
notify:
- restart apache2
@@ -53,6 +76,7 @@
dest: /etc/apache2/sites-enabled/{{ item | basename }}
with_fileglob:
- apache2/templates/*.conf
+ register: apache2_templates
notify:
- restart apache2
@@ -61,6 +85,36 @@
content: "{{ item.value }}"
dest: "/etc/apache2/sites-enabled/{{ item.file }}.conf"
with_items: tmpl
+ register: apache2_proxies
+ when: tmpl
+ notify:
+ - restart apache2
+
+ - name: find existing files
+ find:
+ paths: /etc/apache2/sites-enabled
+ patterns: "*.conf"
+ register: existing_files
+
+ - name: debug
+ debug:
+ var: "{{ item }}"
+ with_items:
+ - apache2_proxies
+ - apache2_templates
+ - existing_files
+
+ - name: remove stale files
+ file: path="{{ item }}" state=absent
+ with_items:
+ existing_files.files|default([])|map(attribute='path')|list|
+ difference(
+ apache2_proxies.results|default([])|rejectattr("dest", "none")|map(attribute='dest')|list
+ )|
+ difference(
+ apache2_templates.results|default([])|map(attribute='path')|list
+ )|
+ default([])
notify:
- restart apache2
diff --git a/apache2/macro.conf b/apache2/conf/macro.conf
similarity index 92%
rename from apache2/macro.conf
rename to apache2/conf/macro.conf
index d47b619..bab5375 100644
--- a/apache2/macro.conf
+++ b/apache2/conf/macro.conf
@@ -34,18 +34,7 @@
-
-
- ServerAdmin rudolfss13@gmail.com
- ServerName $domain.com.ua
-
- ProxyPass $proxyPrefix $proxyUrl retry=0
- ProxyPassReverse $proxyPrefix $proxyUrl
-
-
-
-
-
+
ServerAdmin rudolfss13@gmail.com
@@ -58,15 +47,23 @@
-
+
+ ServerAdmin rudolfss13@gmail.com
+ ServerName $domain.com.ua
+
+ ProxyPass $proxyPrefix $proxyUrl retry=0
+ ProxyPassReverse $proxyPrefix $proxyUrl
+
+
+
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/$domain.com.ua/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/$domain.com.ua/privkey.pem
- SSLCertificateChainFile /etc/letsencrypt/live/$domain.com.ua/chain.pem
+ SSLCertificateChainFile /etc/letsencrypt/live/$domain.com.ua/chain.pem
diff --git a/apache2/conf/server-name.conf b/apache2/conf/server-name.conf
new file mode 100644
index 0000000..a197976
--- /dev/null
+++ b/apache2/conf/server-name.conf
@@ -0,0 +1 @@
+ServerName rudolf.com.ua
diff --git a/apache2/templates/default.conf b/apache2/templates/000-default.conf
similarity index 87%
rename from apache2/templates/default.conf
rename to apache2/templates/000-default.conf
index 13be420..9abb178 100644
--- a/apache2/templates/default.conf
+++ b/apache2/templates/000-default.conf
@@ -28,4 +28,5 @@
## Virtual hosts
-Use DocRootVHost "rudolf" "/home/www/root"
+# Use DocRootVHost "rudolf" "/home/www/root"
+Use ProxyHost "rudolf" "/" "http://localhost:{{ gogs_port }}/" "rudolf"
diff --git a/apache2/templates/smarthome.conf b/apache2/templates/001-smarthome.conf
similarity index 99%
rename from apache2/templates/smarthome.conf
rename to apache2/templates/001-smarthome.conf
index 35bd701..1c7e99d 100644
--- a/apache2/templates/smarthome.conf
+++ b/apache2/templates/001-smarthome.conf
@@ -10,6 +10,7 @@
SSLCertificateKeyFile /etc/letsencrypt/live/smarthome.rudolf.com.ua/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/smarthome.rudolf.com.ua/chain.pem
+
Use GoogleAuth https://smarthome.rudolf.com.ua/oauth2callback /
diff --git a/jenkins.yaml b/jenkins.yaml
index 3d40417..d9790de 100644
--- a/jenkins.yaml
+++ b/jenkins.yaml
@@ -45,7 +45,7 @@
- "/var/jenkins:/var/jenkins_home"
ports:
- "0.0.0.0:{{ jenkins_port }}:8080"
- - "0.0.0.0:{{ jenkins_ci }}:50000"
+ - "0.0.0.0:{{ jenkins_cli }}:50000"
state: reloaded
- name: install jenkins plugins
@@ -56,15 +56,6 @@
become_user: rudolf
- # - name: Install jenkins plugins
- # get_url:
- # url: http://updates.jenkins-ci.org/latest/{{ item.name }}.hpi
- # dest: /var/jenkins/plugins
- # with_items:
- # - { name: "git"}
- # notify: restart jenkins docker
-
-
handlers:
- name: restart jenkins docker
docker_container:
diff --git a/letsencrypt.yaml b/letsencrypt.yaml
new file mode 100644
index 0000000..0d8c04c
--- /dev/null
+++ b/letsencrypt.yaml
@@ -0,0 +1,61 @@
+---
+- hosts: apache2
+ become: yes
+ vars:
+ domains:
+ - rudolf.com.ua
+ - jenkins.rudolf.com.ua
+ - syncthing.rudolf.com.ua
+ - smarthome.rudolf.com.ua
+ # - static.rudolf.com.ua
+ # - torrent.rudolf.com.ua
+ # - dev.rudolf.com.ua
+ # - ejudge.rudolf.com.ua
+ # - webmin.rudolf.com.ua
+ # - bitsync.rudolf.com.ua
+ # - wa.rudolf.com.ua
+
+
+
+ tasks:
+
+ - name: install letsencrypt
+ apt: name=letsencrypt state=latest
+
+ - name: apache stopped
+ service:
+ name: apache2
+ state: stopped
+ enabled: yes
+
+
+ - name: install certificates
+ shell: "letsencrypt certonly --standalone -n -d {{ item }} --email aleksander.rudenko.g@gmail.com --agree-tos"
+ with_items: domains
+
+
+ - name: apache sarted
+ service:
+ name: apache2
+ state: started
+ enabled: yes
+
+
+ # rudolf.com.ua
+# jenkins.rudolf.com.ua
+# torrent.rudolf.com.ua
+# syncthing.rudolf.com.ua
+# dev.rudolf.com.ua
+# ejudge.rudolf.com.ua
+# webmin.rudolf.com.ua
+# smarthome.rudolf.com.ua
+# bitsync.rudolf.com.ua
+# wa.rudolf.com.ua
+# static.rudolf.com.ua
+
+
+
+ # ./letsencrypt-auto renew --standalone
+# ./letsencrypt-auto certonly --standalone -d rudolf.com.ua
+
+