Auf dem Heimischen (Debian/Ubuntu-)Rechner Ansible wie folgt installieren:
sudo apt-get install ansible
Da die Container via SSH nur mit einem Hop über den host erreichbar sind, empfiehlt sich folgende Konfiguration in der ~/.ssh/config
Host 138.201.246.25 HostName bytecluster0002.bytespeicher.org ForwardAgent yes IdentityFile /home/chaos/.ssh/<private key file> User <username> Host 10.2.0.10 HostName 10.2.0.10 User <username> IdentityFile /home/chaos/.ssh/<private key file> ProxyCommand ssh -W %h:%p 138.201.246.25
jeweils natürlich mit dem eigenen Loginnamen und dem Link zum key file. Als Test sollte jetzt bereits
ssh 10.2.0.10
mit nur einem Command zum Zielsystem führen.
Die hosts Datei im Ansible-Verzeichnis kann jetzt z.B. Aliases für die Container und den Host enthalten.
bytecluster ansible_host=bytecluster0002.bytespeicher.org ansible_user=<username> ansible_ssh_private_key_file=~/.ssh/<private key file> web ansible_host=10.2.0.10 ansible_user=<username>
jeweils wieder mit passendem Nutzernamen und Link zum private key. Jetzt sollte
ansible web -a "hostname"
funktionieren und ein Ergebnis vom Zielcontainer bringen.
- name: Setup dokuwiki site
hosts: web
become: yes
tasks:
- name: install apt packages
apt:
pkg:
- git
- python3
- metastore
- php7.3
- php7.3-cli
- php7.3-gd
- php7.3-fpm
- php7.3-xml
- php7.3-zip
state: present
update_cache: yes
force_apt_get: True
- name: Create dokuwiki dir
file:
path: /var/www/dokuwiki
state: directory
owner: www-data
group: www-data
mode: '0755'
- name: Download dokuwiki and unpack
unarchive:
src: https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
dest: /var/www/dokuwiki
owner: www-data
group: www-data
remote_src: yes
- name: Remove file packed file
file:
path: /var/www/dokuwiki/dokuwiki-stable.tgz
state: absent
- name: copy nginx config
copy:
src: ./conf/dokuwiki.conf
dest: /etc/nginx/sites-available/
owner: root
group: root
mode: '0744'
- name: Create a symbolic link
file:
src: /etc/nginx/sites-available/dokuwiki.conf
dest: /etc/nginx/sites-enabled/dokuwiki.conf
owner: root
group: root
state: link
- name: load php-fpm
systemd:
state: restarted
name: php7.3-fpm
- name: Restart service cron on centos, in all cases, also issue daemon-reload to pick up config changes
systemd:
state: restarted
daemon_reload: yes
name: nginx
server {
#listen [::]:443 ssl;
#listen 443 ssl;
listen [::]:8088;
listen 8088; # RSA
#ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
#ssl_certificate_key /etc/letsencrypt/example.com/private.key;
# ECC
#ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
#ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
server_name wiki.technikkultur-erfurt.de;
root /var/www/dokuwiki;
index index.html index.htm index.php doku.php;
client_max_body_size 15M;
client_body_buffer_size 128K;
location / { try_files $uri $uri/ @dokuwiki; }
location ^~ /conf/ { return 403; }
location ^~ /data/ { return 403; }
location ~ /\.ht { deny all; }
location @dokuwiki { rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
rewrite ^/(.*) /doku.php?id=$1 last; }
location ~ \.php$ { try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
sudo rm /var/www/dokuwiki/dokuwiki-2020-07-29/install.php
siehe test-container Proxmox container 'nextcloud.test'