From bbb84079df7fdac692326ed39c2fcb0a52552b8a Mon Sep 17 00:00:00 2001 From: dimti Date: Tue, 2 Jul 2024 08:47:01 +0300 Subject: [PATCH] + php-composer install own playbook with version downgrade for oldest php 7.4 * automatic detect php version and set php extension (for =>8 php version without installing gd, because Debian 11 need libgd3 fix for that) * mapping tld hostname for non-www redirection moved to conf.d and copy that file to remote machine with others existing map-files * some features in this commit not to be a tested in real environment --- .../files/etc/nginx/conf.d/map_tld_domain.conf | 4 ++++ .../debops/files/etc/nginx/includes.d/non-www.conf | 5 ----- playbooks/debops/nginx.yml | 6 ++++++ playbooks/nginx-site.yml | 2 ++ playbooks/own/libgd3-fix-for-php8.yml | 1 + playbooks/own/php-composer.yml | 23 ++++++++++++++++++++++ 6 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 playbooks/debops/files/etc/nginx/conf.d/map_tld_domain.conf create mode 100644 playbooks/own/php-composer.yml diff --git a/playbooks/debops/files/etc/nginx/conf.d/map_tld_domain.conf b/playbooks/debops/files/etc/nginx/conf.d/map_tld_domain.conf new file mode 100644 index 0000000..9185beb --- /dev/null +++ b/playbooks/debops/files/etc/nginx/conf.d/map_tld_domain.conf @@ -0,0 +1,4 @@ +map $host $tld { + default $host; + '~^www\.(?.*)$' $domain; +} diff --git a/playbooks/debops/files/etc/nginx/includes.d/non-www.conf b/playbooks/debops/files/etc/nginx/includes.d/non-www.conf index ffd1596..fb5ac1f 100644 --- a/playbooks/debops/files/etc/nginx/includes.d/non-www.conf +++ b/playbooks/debops/files/etc/nginx/includes.d/non-www.conf @@ -6,11 +6,6 @@ if ( $http_host ~* "^www\.") { if ( $nonwww ~* "^0+$" ) { return 418; } -# TODO: map need moved to conf.d -map $host $tld { - default $host; - '~^www\.(?.*)$' $domain; -} location @nonwww { rewrite ^ https://$tld$request_uri permanent; } diff --git a/playbooks/debops/nginx.yml b/playbooks/debops/nginx.yml index f49f368..054aa7e 100644 --- a/playbooks/debops/nginx.yml +++ b/playbooks/debops/nginx.yml @@ -77,6 +77,12 @@ dest: /etc/nginx/ mode: 0644 + - name: Copy map config for www/non-www redirects + copy: + src: etc/nginx/conf.d/map_tld_domain.conf + dest: /etc/nginx/conf.d/ + mode: 0644 + post_tasks: - name: Default index.html template: diff --git a/playbooks/nginx-site.yml b/playbooks/nginx-site.yml index 6be256e..2f11391 100644 --- a/playbooks/nginx-site.yml +++ b/playbooks/nginx-site.yml @@ -5,6 +5,7 @@ - import_playbook: debops/mariadb_server.yml - import_playbook: debops/mariadb-custom-db.yml - import_playbook: debops/php-prod.yml +- import_playbook: own/libgd3-fix-for-php8.yml - import_playbook: debops/nginx.yml - import_playbook: debops/redis.yml - import_playbook: own/var-www-set-ownerships.yml @@ -14,6 +15,7 @@ - import_playbook: own/nginx-auth.yml - import_playbook: own/phpmyadmin.yml - import_playbook: own/phpmyadmin-nginx-auth.yml +- import_playbook: own/php-composer.yml #- import_playbook: own/correct-paths-for-pct-enter.yml # Import all other group playbooks in this file... diff --git a/playbooks/own/libgd3-fix-for-php8.yml b/playbooks/own/libgd3-fix-for-php8.yml index 1693ae7..3619a9f 100644 --- a/playbooks/own/libgd3-fix-for-php8.yml +++ b/playbooks/own/libgd3-fix-for-php8.yml @@ -1,6 +1,7 @@ --- - name: Solve problem with libgd3 for php-gd hosts: [ 'debian10' ] + when: (php_version != '7.4') vars_files: - ./../../vars/php.yml tasks: diff --git a/playbooks/own/php-composer.yml b/playbooks/own/php-composer.yml new file mode 100644 index 0000000..89e2f2c --- /dev/null +++ b/playbooks/own/php-composer.yml @@ -0,0 +1,23 @@ +--- + +- name: Install PHP Composer + + collections: [ 'debops.debops', 'debops.roles01', + 'debops.roles02', 'debops.roles03' ] + + hosts: [ 'debian10' ] + + tasks: + - name: Download and install composer + when: (php_version is defined) + shell: |- + php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" + php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" + php composer-setup.php + php -r "unlink('composer-setup.php');" + mv composer.phar /usr/local/bin/composer + + - name: Download and install composer + when: (php_version is defined and php_version == '7.4') + shell: |- + composer self-update 1.10.27