]> gitweb.hamatoma.de Git - nest_ansible.git/commitdiff
V0.1.0: first working version as ansknife
authorHamatoma <author@hamatoma.de>
Sat, 5 Apr 2025 17:49:15 +0000 (19:49 +0200)
committerHamatoma <author@hamatoma.de>
Sat, 5 Apr 2025 17:49:15 +0000 (19:49 +0200)
33 files changed:
.gitignore
CHANGELOG.md
SetRights [new symlink]
playbooks/i_10_basic.yaml [changed from file to symlink]
playbooks/i_15_server_packages.yaml [new symlink]
playbooks/i_20_nginx.yaml [changed from file to symlink]
playbooks/i_30_mariadb.yaml [changed from file to symlink]
playbooks/i_40_php8.2.yaml [changed from file to symlink]
playbooks/i_50_git_server.yaml [new symlink]
playbooks/i_99_test.yaml [changed from file to symlink]
playbooks/mysql_create_admin.yaml [new symlink]
playbooks/mysql_create_db_and_user copy.yaml [new symlink]
playbooks/mysql_create_db_and_user.yaml [new symlink]
playbooks/var/php.yaml [deleted file]
playbooks/var/ssl-certificate.yaml [deleted file]
playbooks/webapp_create.yaml [new symlink]
playbooks/webapp_export.yaml [new symlink]
playbooks/webapp_import.yaml [new symlink]
resources/needed.tgz
resources/rsh.tgz
scripts/CreatePlaybook [new symlink]
scripts/CreateTask [new symlink]
tasks/t_mysql_create_admin.yaml [new symlink]
tasks/t_mysql_create_db_and_user.yaml [new symlink]
tasks/t_webapp_create.yaml [new symlink]
tasks/t_webapp_export.yaml [new symlink]
tasks/t_webapp_import.yaml [new symlink]
var/common.yaml [new file with mode: 0644]
var/db.yaml [new file with mode: 0644]
var/php.yaml [new file with mode: 0644]
var/ssl-certificate.yaml [new file with mode: 0644]
var/vault_db.yaml [new file with mode: 0644]
var/webapps.yaml [new file with mode: 0644]

index 722d5e71d93ca0aa0db6fd22452e46be5604a84d..0d806dfa85169696c22a8e69681d0ac100a33231 100644 (file)
@@ -1 +1,2 @@
 .vscode
+.vault
index 51ee0d2686996a2e19fa5e7a33679fca3fadea61..1ec6b54d70eb70a3e421e5c234b51e7256a9c339 100644 (file)
@@ -1 +1,3 @@
 # Change log of 
+## V0.1.0: first working version as ansknife
+
diff --git a/SetRights b/SetRights
new file mode 120000 (symlink)
index 0000000..6172707
--- /dev/null
+++ b/SetRights
@@ -0,0 +1 @@
+../ansknife/SetRights
\ No newline at end of file
deleted file mode 100644 (file)
index a5f64dfe5e84316f4dae59773cd8429803fc1f05..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,43 +0,0 @@
----
-
-- hosts: all
-  vars:
-    hostname: "nest"
-  tasks:
-    - name: Prepare /media/trg directory
-      file: path=/media/trg state=directory
-    - name: Prepare /media/tmp directory
-      file: path=/media/trg state=directory
-    - name: Prepare /media/fs.cave directory
-      file: path=/media/fs.cave state=directory
-    - name: Prepare /media/fs.sys directory
-      file: path=/media/fs.sys state=directory
-    - name: Prepare /usr/local/bin directory
-      file: path=/usr/local/bin state=directory
-    - name: Prepare /usr/local/bin/local directory
-      file: path=/usr/local/bin/local state=directory
-    - name: Prepare /usr/share/pyrshell directory
-      file: path=/usr/share/pyrshell state=directory
-    - name: Symbolic link to local directory
-      file: src=/usr/local/bin/local dest=/usr/local/bin/{{hostname}} state=link
-    - name: Unpack a tar into /usr/local/bin/local
-      unarchive: src=../resources/needed.tgz dest=/usr/local/bin
-    - name: Symbolic link to /p
-      file: src=/usr/local/bin/std.profile dest=/p state=link
-    - name: Unpack a tar into /usr/share/pyrshell
-      unarchive: src=../resources/rsh.tgz dest=/usr/share/pyrshell
-    - name: Create user bupsrv
-      user: name=bupsrv state=present uid=201
-    - name: Create user bupsupply
-      user: name=bupsupply state=present uid=202
-    - name: Create user bupwiki
-      user: name=bupwiki state=present uid=203
-    - name: Create user buptmp
-      user: name=buptmp state=present uid=204
-    - name: Create user extdata
-      user: name=extdata state=present uid=211
-    - name: Create user extcloud
-      user: name=extcloud state=present uid=212
-    - name: Create user extbup
-      user: name=extbup state=present uid=213
-     
\ No newline at end of file
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..4250d9d798062e4931a3350cabbe9f4e48046307
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/i_10_basic.yaml
\ No newline at end of file
diff --git a/playbooks/i_15_server_packages.yaml b/playbooks/i_15_server_packages.yaml
new file mode 120000 (symlink)
index 0000000..5d15839
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/i_15_server_packages.yaml
\ No newline at end of file
deleted file mode 100644 (file)
index 99e2f6744fbe5e3e728fe7d6cdd0b50e0e671fc8..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,61 +0,0 @@
----
-- name: Install and configure with letsencrypt
-  hosts: all
-  become: yes
-
-  vars:
-    user: www-data
-    hostname: "{{ inventory_hostname }}"
-    log_name: "{{ inventory_hostname | regex_search('[0-9a-zA-Z_]+') }}"
-  vars_files:
-    - var/ssl-certificate.yaml
-  tasks:
-    - name: Install nginx
-      apt:
-        name: nginx
-        state: latest
-        update_cache: yes
-    - name: Prepare letsencrypt home directory
-      file: path=/home/www/letsencrypt/.well-known/acme-challenge state=directory
-    - name: Add test file1
-      copy: src=../templates/nginx/hi1.txt dest=/home/www/letsencrypt/.well-known/
-    - name: Add test file2
-      copy: src=../templates/nginx/hi2.txt dest=/home/www/letsencrypt/.well-known/acme-challenge/hi2.txt
-    - name: Prepare letsencrypt
-      copy:
-        src: ../templates/nginx/letsencrypt.conf
-        dest: /etc/nginx/snippets
-    - name: add HTTP-variables
-      copy:
-        src: ../templates/nginx/http.conf
-        dest: /etc/nginx/snippets
-    - name: create a www directory
-      file: path=/home/www state=directory owner=root group=www-data
-      
-    - name: create the /srv/www link
-      file: src=/home/www dest=/srv/www state=link
-    - name: Ensure nginx is running
-      systemd:
-        name: nginx
-        state: started
-        enabled: yes
-    - name: create a test virtual hosts
-      template: 
-        src: ../templates/nginx/test.site
-        dest: /etc/nginx/sites-available/{{hostname}}
-    - name: activate by link in sites-enabled
-      file:
-        src: /etc/nginx/sites-available/{{hostname}}
-        dest: /etc/nginx/sites-enabled/{{hostname}}
-        state: link
-    - name: create a ssh-certificate
-      command: openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/{{hostname}}.key -out /etc/ssl/certs/{{hostname}}.pem -subj "/C={{SSL_COUNTRY}}/ST={{SSL_STATE}}/L={{SSL_LOCALITY}}/O={{SSL_ORGANIZATION}}/CN={{hostname}}"
-      args:
-        creates: /etc/ssl/private/{{hostname}}.key
-    - name: create a document root
-      file: dest=/srv/www/{{hostname}} state=directory owner=www-data group=www-data
-    - name: create a test index.html
-      template: src=../templates/nginx/index.html dest=/srv/www/{{hostname}}/index.html
-    - name: create a test index.php
-      copy: src=../templates/nginx/index.php dest=/srv/www/{{hostname}}/index.php
-
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..fef466114dc680116d341da11c27494440ae3aff
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/i_20_nginx.yaml
\ No newline at end of file
deleted file mode 100644 (file)
index a5852e1e4b1475f4500b014ede3d3406afd3395e..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,16 +0,0 @@
-- hosts: all
-  vars:
-    - PHP_VERS: "8.3"
-
-  tasks:
-    - name: Install mariadb
-      ansible.builtin.apt:
-        name:
-          - mariadb-server
-        state: latest
-        update_cache: yes
-    - name: Ensure mariadb is running
-      ansible.builtin.systemd:
-        name: mysqld
-        state: started
-        enabled: yes
\ No newline at end of file
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..d1c8dd242e3c12d59b016aadac9445eec2803ba1
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/i_30_mariadb.yaml
\ No newline at end of file
deleted file mode 100644 (file)
index d2a6d1792e160830a8fe92c8a7ebd94b370ec6fe..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,50 +0,0 @@
-- hosts: all
-  vars:
-    - PHP_VERS: "8.2"
-  vars_files:
-    - var/php.yaml
-  pre_tasks:
-    - name:
-      apt:
-        name: gpg
-        state: present
-        update_cache: true
-    - name: add packages.sury.org (Debian case)
-      block:
-        - name: add gpg repo key
-          apt_key:
-            url:  'https://packages.sury.org/php/apt.gpg'
-            state: present
-
-        - name: add apt repo
-          apt_repository:
-            repo:  'deb https://packages.sury.org/php/ {{ ansible_distribution_release|lower }} main'
-            state: present
-            filename: php
-      when: ansible_distribution == 'Debian'
-  tasks:
-    - name: Install PHP {{PHP_VERS}} and common modules
-      ansible.builtin.apt:
-        name: "{{ item }}"
-        state: present
-        update_cache: true
-        cache_valid_time: 3600
-      with_items: "{{ php_packages + php_additional_packages }}"
-    - name: Define PHP variables in php.ini
-      ansible.builtin.ini_file:
-        dest: /etc/php/{{PHP_VERS}}/fpm/php.ini 
-        section: "{{ item.section }}"
-        option: "{{ item.option }}"
-        value: "{{ item.value }}"
-      with_items:
-        "{{ php_ini_settings }}"
-    - name: Ensure PHP-FPM is running
-      ansible.builtin.systemd:
-        name: php{{PHP_VERS}}-fpm
-        state: started
-        enabled: yes
-    - name: Ensure Redis is running
-      ansible.builtin.systemd:
-        name: redis-server
-        state: started
-        enabled: yes
\ No newline at end of file
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..37b9910208535b93aae4afc7edc04f19f9f5fd1c
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/i_40_php8.2.yaml
\ No newline at end of file
diff --git a/playbooks/i_50_git_server.yaml b/playbooks/i_50_git_server.yaml
new file mode 120000 (symlink)
index 0000000..31bad60
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/i_50_git_server.yaml
\ No newline at end of file
deleted file mode 100644 (file)
index e21156f0fa9e3fafd3738e2050159644ca09e117..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,15 +0,0 @@
----
-- name: Install and configure with letsencrypt
-  hosts: all
-  become: yes
-
-  vars:
-    user: www-data
-    hostname: "{{ inventory_hostname }}"
-    log_name: "{{ inventory_hostname | regex_search('[0-9a-zA-Z_]+') }}"
-  vars_files:
-    - var/ssl-certificate.yaml
-  tasks:
-    - name: Install nginx
-      debug: 
-        msg: "hostname: {{hostname}} log_name: {{log_name}}"
\ No newline at end of file
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..e7ae028ed22d8e7d71a4af18b1e6c9a4f5c29174
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/i_99_test.yaml
\ No newline at end of file
diff --git a/playbooks/mysql_create_admin.yaml b/playbooks/mysql_create_admin.yaml
new file mode 120000 (symlink)
index 0000000..9ebc574
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/mysql_create_admin.yaml
\ No newline at end of file
diff --git a/playbooks/mysql_create_db_and_user copy.yaml b/playbooks/mysql_create_db_and_user copy.yaml
new file mode 120000 (symlink)
index 0000000..33e8e09
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/mysql_create_db_and_user.yaml
\ No newline at end of file
diff --git a/playbooks/mysql_create_db_and_user.yaml b/playbooks/mysql_create_db_and_user.yaml
new file mode 120000 (symlink)
index 0000000..33e8e09
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/mysql_create_db_and_user.yaml
\ No newline at end of file
diff --git a/playbooks/var/php.yaml b/playbooks/var/php.yaml
deleted file mode 100644 (file)
index 5bc552c..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
----
-# php.yaml:
-# Defines variables for the PHP role.
-# This file is used to set up the PHP environment and configuration.
-# needed variables: PHP_VERS
-
-php_packages:
-  - php{{PHP_VERS}}-common
-  - php{{PHP_VERS}}-curl
-  - php{{PHP_VERS}}-fpm
-  - php{{PHP_VERS}}-gd
-  - php{{PHP_VERS}}-igbinary
-  - php{{PHP_VERS}}-imagick
-  - php{{PHP_VERS}}-imap
-  - php{{PHP_VERS}}-intl
-  - php{{PHP_VERS}}-mbstring
-  - php{{PHP_VERS}}-memcached
-  - php{{PHP_VERS}}-msgpack
-  - php{{PHP_VERS}}-mysql
-  - php{{PHP_VERS}}-opcache
-  - php{{PHP_VERS}}-phpdbg
-  - php{{PHP_VERS}}-readline
-  - php{{PHP_VERS}}-redis
-  - php{{PHP_VERS}}-xdebug
-  - php{{PHP_VERS}}-xml
-  - php{{PHP_VERS}}-zip
-php_additional_packages:
-  - redis-server
-  - imagemagick
-
-php_ini_settings:
-  - { section: "DEFAULT", option: "memory_limit", value: "512M" }
-  - { section: "DEFAULT", option: "upload_max_filesize", value: "512M" }
-  - { section: "DEFAULT", option: "max_file_uploads", value: 100 }
-  - { section: "DEFAULT", option: "post_max_size", value: "512M" }
-  - { section: "DEFAULT", option: "max_execution_time", value: 600 }
-  - { section: "DEFAULT", option: "max_input_time", value: 600 }
-  - { section: "DEFAULT", option: "default_socket_timeout", value: 600 }
-  - { section: "Session", option: "session.save_handler", value: "redis" }
-  - { section: "Session", option: "session.save_path", value: "tcp://127.0.0.1:6379" }
-  - { section: "opcache", option: "opcache.enable", value: 1 }
-  - { section: "opcache", option: "opcache.memory_consumption", value: 512 }
-  - { section: "opcache", option: "opcache.interned_strings_buffer", value: 256 }
-
diff --git a/playbooks/var/ssl-certificate.yaml b/playbooks/var/ssl-certificate.yaml
deleted file mode 100644 (file)
index 07bc809..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
----
-# "/C=DE/ST=NRW/L=Bochum/O=IT/CN={{hostname}}"
-SSL_COUNTRY: DE
-SSL_STATE: Bavaria
-SSL_LOCALITY: Kempten
-SSL_ORGANIZATION: IT
-
diff --git a/playbooks/webapp_create.yaml b/playbooks/webapp_create.yaml
new file mode 120000 (symlink)
index 0000000..b9d23a9
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/webapp_create.yaml
\ No newline at end of file
diff --git a/playbooks/webapp_export.yaml b/playbooks/webapp_export.yaml
new file mode 120000 (symlink)
index 0000000..0d1daad
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/webapp_export.yaml
\ No newline at end of file
diff --git a/playbooks/webapp_import.yaml b/playbooks/webapp_import.yaml
new file mode 120000 (symlink)
index 0000000..a06bb76
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/playbooks/webapp_import.yaml
\ No newline at end of file
index 0da7040da7584a42547a03ef34b1a66513df418e..3c4ed1f9eec92490b85c6623aadb50dc00fb1bef 120000 (symlink)
@@ -1 +1 @@
-../../common/resources/needed.tgz
\ No newline at end of file
+../../ansknife/resources/needed.tgz
\ No newline at end of file
index fda2b9c6e2882747543f9d90610b8310c48333a4..103074561b637ec74178954c690772e843a398fb 120000 (symlink)
@@ -1 +1 @@
-../../common/resources/rsh.tgz
\ No newline at end of file
+../../ansknife/resources/rsh.tgz
\ No newline at end of file
diff --git a/scripts/CreatePlaybook b/scripts/CreatePlaybook
new file mode 120000 (symlink)
index 0000000..71ad78a
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/scripts/CreatePlaybook
\ No newline at end of file
diff --git a/scripts/CreateTask b/scripts/CreateTask
new file mode 120000 (symlink)
index 0000000..af89d80
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/scripts/CreateTask
\ No newline at end of file
diff --git a/tasks/t_mysql_create_admin.yaml b/tasks/t_mysql_create_admin.yaml
new file mode 120000 (symlink)
index 0000000..0df504c
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/tasks/t_mysql_create_admin.yaml
\ No newline at end of file
diff --git a/tasks/t_mysql_create_db_and_user.yaml b/tasks/t_mysql_create_db_and_user.yaml
new file mode 120000 (symlink)
index 0000000..f91e0db
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/tasks/t_mysql_create_db_and_user.yaml
\ No newline at end of file
diff --git a/tasks/t_webapp_create.yaml b/tasks/t_webapp_create.yaml
new file mode 120000 (symlink)
index 0000000..194111e
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/tasks/t_webapp_create.yaml
\ No newline at end of file
diff --git a/tasks/t_webapp_export.yaml b/tasks/t_webapp_export.yaml
new file mode 120000 (symlink)
index 0000000..7df312c
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/tasks/t_webapp_export.yaml
\ No newline at end of file
diff --git a/tasks/t_webapp_import.yaml b/tasks/t_webapp_import.yaml
new file mode 120000 (symlink)
index 0000000..fe09c5c
--- /dev/null
@@ -0,0 +1 @@
+../../ansknife/tasks/t_webapp_import.yaml
\ No newline at end of file
diff --git a/var/common.yaml b/var/common.yaml
new file mode 100644 (file)
index 0000000..9031605
--- /dev/null
@@ -0,0 +1,3 @@
+configuration_directory: /etc/ansknife
+remote_webapps_directory: "{{ configuration_directory }}/webapps.d"
+local_webapps_directory: "../webapps"
\ No newline at end of file
diff --git a/var/db.yaml b/var/db.yaml
new file mode 100644 (file)
index 0000000..e713d30
--- /dev/null
@@ -0,0 +1,8 @@
+---
+# Creation of the central password file:
+# echo "top_secret_password" > resources/.vaults
+# Creation of the encrypted vault file:
+# ansible-vault encrypt_string --vault-password-file resources/.vault --name 'vault_dba_password' --stdin-name 'vault_dba_password' | tee var/vault_db.yaml
+# Find the password file: ANSIBLE_VAULT_PASSWORD_FILE=resources/.vault
+dba_name: dba
+dba_password: "{{ vault_dba_password }}"
\ No newline at end of file
diff --git a/var/php.yaml b/var/php.yaml
new file mode 100644 (file)
index 0000000..5bc552c
--- /dev/null
@@ -0,0 +1,44 @@
+---
+# php.yaml:
+# Defines variables for the PHP role.
+# This file is used to set up the PHP environment and configuration.
+# needed variables: PHP_VERS
+
+php_packages:
+  - php{{PHP_VERS}}-common
+  - php{{PHP_VERS}}-curl
+  - php{{PHP_VERS}}-fpm
+  - php{{PHP_VERS}}-gd
+  - php{{PHP_VERS}}-igbinary
+  - php{{PHP_VERS}}-imagick
+  - php{{PHP_VERS}}-imap
+  - php{{PHP_VERS}}-intl
+  - php{{PHP_VERS}}-mbstring
+  - php{{PHP_VERS}}-memcached
+  - php{{PHP_VERS}}-msgpack
+  - php{{PHP_VERS}}-mysql
+  - php{{PHP_VERS}}-opcache
+  - php{{PHP_VERS}}-phpdbg
+  - php{{PHP_VERS}}-readline
+  - php{{PHP_VERS}}-redis
+  - php{{PHP_VERS}}-xdebug
+  - php{{PHP_VERS}}-xml
+  - php{{PHP_VERS}}-zip
+php_additional_packages:
+  - redis-server
+  - imagemagick
+
+php_ini_settings:
+  - { section: "DEFAULT", option: "memory_limit", value: "512M" }
+  - { section: "DEFAULT", option: "upload_max_filesize", value: "512M" }
+  - { section: "DEFAULT", option: "max_file_uploads", value: 100 }
+  - { section: "DEFAULT", option: "post_max_size", value: "512M" }
+  - { section: "DEFAULT", option: "max_execution_time", value: 600 }
+  - { section: "DEFAULT", option: "max_input_time", value: 600 }
+  - { section: "DEFAULT", option: "default_socket_timeout", value: 600 }
+  - { section: "Session", option: "session.save_handler", value: "redis" }
+  - { section: "Session", option: "session.save_path", value: "tcp://127.0.0.1:6379" }
+  - { section: "opcache", option: "opcache.enable", value: 1 }
+  - { section: "opcache", option: "opcache.memory_consumption", value: 512 }
+  - { section: "opcache", option: "opcache.interned_strings_buffer", value: 256 }
+
diff --git a/var/ssl-certificate.yaml b/var/ssl-certificate.yaml
new file mode 100644 (file)
index 0000000..07bc809
--- /dev/null
@@ -0,0 +1,7 @@
+---
+# "/C=DE/ST=NRW/L=Bochum/O=IT/CN={{hostname}}"
+SSL_COUNTRY: DE
+SSL_STATE: Bavaria
+SSL_LOCALITY: Kempten
+SSL_ORGANIZATION: IT
+
diff --git a/var/vault_db.yaml b/var/vault_db.yaml
new file mode 100644 (file)
index 0000000..4830f1e
--- /dev/null
@@ -0,0 +1 @@
+vault_dba_password: Sekret.Top
\ No newline at end of file
diff --git a/var/webapps.yaml b/var/webapps.yaml
new file mode 100644 (file)
index 0000000..40f6e88
--- /dev/null
@@ -0,0 +1,11 @@
+webapps_list:
+  - webapp_name: myapp5.example.com
+    db_name: dbdummy5
+    db_user: dummy5
+    db_password: NeverKnown5
+    directory: /srv/www/myapp5.example.com
+  - webapp_name: 'app7.example.com'
+    db_name: 'dbapp7'
+    db_user: 'appusr7'
+    db_password: 'Unknown7'
+    directory: '/srv/www/app7.example.com'