From d28e254be8f7743654471f9889680bfc271e19a2 Mon Sep 17 00:00:00 2001 From: rudolf Date: Wed, 2 Dec 2020 23:35:47 +0300 Subject: [PATCH] Fixed all --- all.sh | 0 all.yaml | 44 +++++++++++++------ gogs.yaml | 35 +++++++++++++++ group_vars/all | 2 +- hosts | 8 ++-- requirements.sh | 3 ++ requirements.yaml | 2 + roles/adm/handlers/main.yml | 2 + roles/adm/tasks/main.yaml | 19 +++++++- roles/apache2/tasks/main.yml | 4 +- .../files/templates/000-default.conf | 16 ------- .../files/templates/001-smarthome.conf | 15 +++++-- roles/gogs/handlers/main.yml | 5 --- roles/gogs/meta/main.yml | 15 ------- roles/gogs/tasks/main.yaml | 31 ------------- roles/pptp_server/files/chap-secrets | 3 ++ roles/pptp_server/handlers/main.yml | 2 + roles/pptp_server/tasks/main.yml | 41 +++++++++++++++++ syncthing.yaml | 42 ++++++++++++++++++ 19 files changed, 198 insertions(+), 91 deletions(-) create mode 100644 all.sh create mode 100644 gogs.yaml create mode 100644 requirements.sh create mode 100644 requirements.yaml delete mode 100644 roles/apache2config/files/templates/000-default.conf delete mode 100644 roles/gogs/handlers/main.yml delete mode 100644 roles/gogs/meta/main.yml delete mode 100644 roles/gogs/tasks/main.yaml create mode 100644 roles/pptp_server/files/chap-secrets create mode 100644 roles/pptp_server/handlers/main.yml create mode 100644 roles/pptp_server/tasks/main.yml create mode 100644 syncthing.yaml diff --git a/all.sh b/all.sh new file mode 100644 index 0000000..e69de29 diff --git a/all.yaml b/all.yaml index 404b78b..da9f53c 100644 --- a/all.yaml +++ b/all.yaml @@ -7,27 +7,29 @@ become: yes roles: - { role: apache2config } - - { role: metricbeat } - + - { role: 0x0i.systemd } +# TODO +# https://ru.alxschwarz.com/posts/sshfs-with-password-in-systemd/ vars: tmpl: - - { file: "101-syncthing", value: 'Use ProxyHost "syncthing.rudolf" "/" "http://192.168.17.2:{{ syncthing_port }}/" "syncthing.rudolf"' } - - { file: "102-jenkins", value: 'Use ProxyHost "jenkins.rudolf" "/" "http://192.168.17.2:{{ jenkins_port }}/" "jenkins.rudolf"' } - - { file: "103-zabbix", value: 'Use ProxyHost "zabbix.rudolf" "/" "http://94.177.197.15:8081/" "zabbix.rudolf"' } + - { file: "000-gogs", value: 'Use ProxyHost "rudolf" "/" "http://192.168.17.4:{{ gogs_port }}/" "rudolf"' } + - { file: "101-syncthing", value: 'Use ProxyHost "syncthing.rudolf" "/" "http://192.168.17.4:{{ syncthing_port }}/" "syncthing.rudolf"' } + # - { file: "102-jenkins", value: 'Use ProxyHost "jenkins.rudolf" "/" "http://192.168.17.2:{{ jenkins_port }}/" "jenkins.rudolf"' } + # - { file: "103-zabbix", value: 'Use ProxyHost "zabbix.rudolf" "/" "http://94.177.197.15:8081/" "zabbix.rudolf"' } - { file: "104-ssh", value: 'Use ProxyHost "sh.rudolf" "/" "http://192.168.17.4:4200/" "sh.rudolf"' } - - { file: "torrent", value: 'Use ProxyHost "torrent.rudolf" "/transmission" "http://192.168.17.2:9091/transmission" "torrent.rudolf"' } + # - { file: "torrent", value: 'Use ProxyHost "torrent.rudolf" "/transmission" "http://192.168.17.2:9091/transmission" "torrent.rudolf"' } # - {file: "static", value: 'Use DocRootVHost "static.rudolf" "/home/www/static"' } # - {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"' } # - {file: "", value: 'Use ProxySSLVHost "bitsync.rudolf" "/" "http://localhost:8888/" "bitsync.rudolf"' } domains: - rudolf.com.ua - - jenkins.rudolf.com.ua + # - jenkins.rudolf.com.ua - syncthing.rudolf.com.ua - smarthome.rudolf.com.ua - - torrent.rudolf.com.ua - - zabbix.rudolf.com.ua + # - torrent.rudolf.com.ua + # - zabbix.rudolf.com.ua - sh.rudolf.com.ua # - part.syncthing.rudolf.com.ua # - static.rudolf.com.ua @@ -36,10 +38,25 @@ # - webmin.rudolf.com.ua # - bitsync.rudolf.com.ua # - wa.rudolf.com.ua - metricbeat_es_user: "metricbeat" - metricbeat_es_password: "metricbeat" - metricbeat_kibana_index: "metricbeat" - elasticsearch_host: "192.168.17.2:9200" + # metricbeat_es_user: "metricbeat" + # metricbeat_es_password: "metricbeat" + # metricbeat_kibana_index: "metricbeat" + # elasticsearch_host: "192.168.17.2:9200" + + unit_config: + - name: mnt-DATA + type: mount + Unit: + Description: Mount DATA fs + Mount: + What: /dev/disk/by-uuid/2DC48EE00DE0CBC9 + Where: /mnt/DATA + Type: ntfs-3g + Options: rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096 + Install: + WantedBy: multi-user.target + + - hosts: serva4og become: yes @@ -51,4 +68,5 @@ become: yes roles: - { role: jdk } +# https://hub.docker.com/r/mmontagna/docker-vpn-pptp/ diff --git a/gogs.yaml b/gogs.yaml new file mode 100644 index 0000000..3c3e3fd --- /dev/null +++ b/gogs.yaml @@ -0,0 +1,35 @@ +- hosts: odroid + become: yes + roles: + - { role: 0x0i.systemd } + + vars: + unit_config: + - name: gogs + Unit: + Description: Gogs git repo service + Service: + User: 'git' + Group: 'git' + WorkingDirectory: /mnt/DATA/gogsRuntime/home + ExecStart: /mnt/DATA/gogsRuntime/dist/gogs web -c /mnt/DATA/gogsRuntime/gogs/conf/app.ini + Install: + WantedBy: multi-user.target + + tasks: + - name: group git exists + group: + name: "git" + state: present + + - name: user git + user: + name: "git" + group: "git" + append: yes + home: /mnt/DATA/gogsRuntime/home + shell: /bin/bash + createhome: yes + generate_ssh_key: yes + state: present + diff --git a/group_vars/all b/group_vars/all index 976e062..b747eec 100644 --- a/group_vars/all +++ b/group_vars/all @@ -1,4 +1,4 @@ -gogs_port: 8081 +gogs_port: 3000 gogs_ssh: 23 jenkins_port: 8080 jenkins_cli: 50000 diff --git a/hosts b/hosts index cd74675..36d9b59 100644 --- a/hosts +++ b/hosts @@ -1,9 +1,9 @@ [online] -serva4og ansible_ssh_user=rudolf ansible_ssh_host=192.168.17.2 odroid ansible_ssh_user=rudolf ansible_ssh_host=192.168.17.4 -main ansible_ssh_user=rudolf ansible_ssh_host=94.177.197.15 +#main ansible_ssh_user=rudolf ansible_ssh_host=94.177.197.15 [offline] -pi ansible_ssh_user=pi ansible_ssh_host=192.168.17.3 -malta4ka ansible_ssh_user=kate ansible_ssh_host=192.168.17.113 +# serva4og ansible_ssh_user=rudolf ansible_ssh_host=192.168.17.2 +# pi ansible_ssh_user=pi ansible_ssh_host=192.168.17.3 +# malta4ka ansible_ssh_user=kate ansible_ssh_host=192.168.17.113 diff --git a/requirements.sh b/requirements.sh new file mode 100644 index 0000000..0e7002b --- /dev/null +++ b/requirements.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +ansible-galaxy install -r requirements.yaml diff --git a/requirements.yaml b/requirements.yaml new file mode 100644 index 0000000..452650b --- /dev/null +++ b/requirements.yaml @@ -0,0 +1,2 @@ +- src: tumf.systemd-service +- src: 0x0i.systemd diff --git a/roles/adm/handlers/main.yml b/roles/adm/handlers/main.yml index bb13913..b58178f 100644 --- a/roles/adm/handlers/main.yml +++ b/roles/adm/handlers/main.yml @@ -1,3 +1,5 @@ - name: sysctl command: sysctl -p +- name: sshd + service: name=ssh state=restarted diff --git a/roles/adm/tasks/main.yaml b/roles/adm/tasks/main.yaml index b180c35..6af52a1 100644 --- a/roles/adm/tasks/main.yaml +++ b/roles/adm/tasks/main.yaml @@ -26,15 +26,32 @@ - name: ssh authorized keys authorized_key: user="{{ user }}" key="{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}" +- name: Disallow password authentication + lineinfile: + dest: /etc/ssh/sshd_config + regexp: "^PasswordAuthentication" + line: "PasswordAuthentication no" + state: present + notify: sshd + +- name: Disallow root SSH access + lineinfile: + dest: /etc/ssh/sshd_config + regexp: "^PermitRootLogin" + line: "PermitRootLogin no" + state: present + notify: sshd + - name: install packages apt: name={{ item }} update_cache=yes state=latest with_items: - git - etckeeper + - zip - name: Remote etc git git_config: - repo: /etc + repo: /etc/ scope: local name: remote.origin.url value: http://rudolf.com.ua/rudolf/etckeeper.git diff --git a/roles/apache2/tasks/main.yml b/roles/apache2/tasks/main.yml index 419111d..12c6812 100644 --- a/roles/apache2/tasks/main.yml +++ b/roles/apache2/tasks/main.yml @@ -26,7 +26,9 @@ - { name: macro , state: present } - { name: auth_openidc , state: present } - { name: ssl , state: present } - - { name: cgid , state: present } + - { name: cgid , state: present } + - { name: proxy_wstunnel, state: present } + # - { name: ssl , state: absent } notify: - restart apache2 diff --git a/roles/apache2config/files/templates/000-default.conf b/roles/apache2config/files/templates/000-default.conf deleted file mode 100644 index 3a11076..0000000 --- a/roles/apache2config/files/templates/000-default.conf +++ /dev/null @@ -1,16 +0,0 @@ - - - - ServerAdmin rudolfss13@gmail.com - ServerName rudolf.com.ua - - #Redirect 404 / - #ErrorDocument 404 "Page Not Found xxx" - - Use MacroSSL rudolf - - - - - -Use ProxyHost "rudolf" "/" "http://192.168.17.2:{{ gogs_port }}/" "rudolf" diff --git a/roles/apache2config/files/templates/001-smarthome.conf b/roles/apache2config/files/templates/001-smarthome.conf index ec11f02..3e99676 100644 --- a/roles/apache2config/files/templates/001-smarthome.conf +++ b/roles/apache2config/files/templates/001-smarthome.conf @@ -13,8 +13,13 @@ Require claim email:malta4ka@gmail.com - ProxyPass / http://192.168.17.4:{{ tomcat_port }}/smarthome/ - ProxyPassReverse / http://192.168.17.4:{{ tomcat_port }}/smarthome/ + RewriteEngine on + RewriteCond ${HTTP:Upgrade} websocket [NC] + RewriteCond ${HTTP:Connection} upgrade [NC] + RewriteRule .* "wss:/192.168.17.4:8888/$1" [P,L] + + ProxyPass / http://192.168.17.4:8888/ + ProxyPassReverse / http://192.168.17.4:8888/ @@ -30,8 +35,10 @@ Allow from 188.134.29.71 - ProxyPass / http://192.168.17.4:{{ tomcat_port }}/smarthome/ - ProxyPassReverse / http://192.168.17.4:{{ tomcat_port }}/smarthome/ + ProxyPass "/rest/ws" "ws://192.168.17.4:8888/rest/ws" + + ProxyPass / http://192.168.17.4:8888/ + ProxyPassReverse / http://192.168.17.4:8888/ diff --git a/roles/gogs/handlers/main.yml b/roles/gogs/handlers/main.yml deleted file mode 100644 index 76eca8e..0000000 --- a/roles/gogs/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: restart gogs docker - service: - name: docker - state: restarted - restart_policy: always diff --git a/roles/gogs/meta/main.yml b/roles/gogs/meta/main.yml deleted file mode 100644 index 156821c..0000000 --- a/roles/gogs/meta/main.yml +++ /dev/null @@ -1,15 +0,0 @@ -galaxy_info: - author: your name - description: your description - company: your company (optional) - - license: license (GPLv2, CC-BY, etc) - - min_ansible_version: 1.2 - - galaxy_tags: [] - -dependencies: - - { role: docker } - - diff --git a/roles/gogs/tasks/main.yaml b/roles/gogs/tasks/main.yaml deleted file mode 100644 index d5d4347..0000000 --- a/roles/gogs/tasks/main.yaml +++ /dev/null @@ -1,31 +0,0 @@ -- name: run gogs docker container - docker: - name: gogs - image: gogs/gogs - detach: True - restart_policy: always - net: default - volumes: - - "/var/gogs:/data" - ports: - - "0.0.0.0:{{ gogs_port }}:3000" - state: reloaded - - -- name: oauth config - blockinfile: - dest: /var/gogs/gogs/conf/app.ini - block: | - [oauth] - ENABLED = true - - [oauth.google] - ENABLED = true - CLIENT_ID = `259977835489-5lrmult5iimh3f7dik848fb00mn8td2j.apps.googleusercontent.com` - CLIENT_SECRET = `3xzC51fw-yBeWv63pxYlmYE7` - SCOPES = `https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile` - AUTH_URL = `https://accounts.google.com/o/oauth2/auth` - TOKEN_URL = `https://accounts.google.com/o/oauth2/token` - - notify: restart gogs docker - diff --git a/roles/pptp_server/files/chap-secrets b/roles/pptp_server/files/chap-secrets new file mode 100644 index 0000000..5507311 --- /dev/null +++ b/roles/pptp_server/files/chap-secrets @@ -0,0 +1,3 @@ +# Secrets for authentication using CHAP +# client server secret IP addresses +rudolf * rudolf-pptpd * diff --git a/roles/pptp_server/handlers/main.yml b/roles/pptp_server/handlers/main.yml new file mode 100644 index 0000000..2e48595 --- /dev/null +++ b/roles/pptp_server/handlers/main.yml @@ -0,0 +1,2 @@ +- name: restart pptpd + service: name=pptpd state=restarted diff --git a/roles/pptp_server/tasks/main.yml b/roles/pptp_server/tasks/main.yml new file mode 100644 index 0000000..cab8708 --- /dev/null +++ b/roles/pptp_server/tasks/main.yml @@ -0,0 +1,41 @@ +- name: install pptpd + apt: name=pptpd update_cache=yes state=latest + + +- name: add users + copy: + src: "files/chap-secrets" + dest: /etc/ppp/chap-secrets + mode: 0600 + notify: restart pptpd + +- name: config 1 + lineinfile: + dest: /etc/pptpd.conf + regexp: "^.*{{ item.line }}" + line: "{{ item.line }}" + state: present + with_items: + - { line: "localip 10.10.10.1" } + - { line: "remoteip 10.10.10.2-10" } + - { line: "bcrelay eth0" } + notify: restart pptpd + +- name: config 2 + lineinfile: + dest: /etc/ppp/pptpd-options + regexp: "^.*{{ item.line }}" + line: "{{ item.line }}" + state: present + with_items: + - { line: "ms-dns 8.8.8.8" } + - { line: "auth" } + - { line: "logfile /var/log/pptpd.log" } + notify: restart pptpd + +- name: pptpd running + service: + name: pptpd + state: started + enabled: yes + diff --git a/syncthing.yaml b/syncthing.yaml new file mode 100644 index 0000000..f5a0c08 --- /dev/null +++ b/syncthing.yaml @@ -0,0 +1,42 @@ +- hosts: odroid + become: yes + roles: + - { role: 0x0i.systemd } + + vars: + unit_config: + - name: syncthing + Unit: + Description: Syncthing - Open Source Continuous File Synchronization + Documentation: man:syncthing(1) + Wants: syncthing-inotify.service + Service: + ExecStart: /usr/bin/syncthing -home=/mnt/DATA/syncthingRuntime -no-browser -no-restart -logflags=0 + User: 'syncthing' + Group: 'syncthing' + Restart: on-failure + SuccessExitStatus: 3 4 + RestartForceExitStatus: 3 4 + Install: + WantedBy: default.target + + + tasks: + - name: install packages + apt: name={{ item }} update_cache=yes state=latest + with_items: + - syncthing + + - name: group syncthing exists + group: + name: "syncthing" + state: present + + - name: user syncthing + user: + name: "syncthing" + group: "syncthing" + append: yes + shell: /bin/bash + state: present +