|
|
@@ -1,28 +1,14 @@
|
|
|
+# Run this with:
|
|
|
+# ansible-playbook -i <inventory> playbooks/install_php_mysql_debian.yml -bkK --limit debian-xyz -e @vars-debian-xyz.yml
|
|
|
---
|
|
|
- name: Install PHP and MySQL on Debian-based systems
|
|
|
hosts: debian
|
|
|
become: yes
|
|
|
- # vars:
|
|
|
- # db_username: wordpress
|
|
|
- # db_password: wordpress
|
|
|
- # db_name: wordpress
|
|
|
- # site_url: debian-111
|
|
|
tasks:
|
|
|
- name: Update apt cache
|
|
|
ansible.builtin.apt:
|
|
|
update_cache: yes
|
|
|
|
|
|
- # Utilisés pour installer/compiler le package python mysqlclient
|
|
|
- # - name: Install gcc, mariadb-dev, pkgconfig and pip3
|
|
|
- # ansible.builtin.apt:
|
|
|
- # name:
|
|
|
- # - gcc # needed to compile
|
|
|
- # - python3-dev # needed to compile
|
|
|
- # # - mariadb-dev
|
|
|
- # - python3-pip
|
|
|
- # # - pkgconfig
|
|
|
- # state: present
|
|
|
-
|
|
|
# Remarque : php 8.2 pour Debian Bookworm
|
|
|
- name: Install PHP
|
|
|
ansible.builtin.apt:
|
|
|
@@ -32,10 +18,8 @@
|
|
|
- php8.2-iconv # for WordPress
|
|
|
- php8.2-mysqli # for WordPress/MySQL
|
|
|
- php8.2-phar # for wp-cli
|
|
|
- # - php8.2-json # for wp-cli
|
|
|
- # pas de package php8.2-openssl pour Debian Bookworm
|
|
|
- # - php8.2-openssl # for wp-cli
|
|
|
- php8.2-curl # for wp-cli
|
|
|
+ - php8.2-gd # WordPress needs this in order to generate thumbnails
|
|
|
state: present
|
|
|
|
|
|
- name: Install curl
|
|
|
@@ -78,37 +62,11 @@
|
|
|
- mariadb-client
|
|
|
state: present
|
|
|
|
|
|
- # - name: Start Nginx Service
|
|
|
- # ansible.builtin.service:
|
|
|
- # name: nginx
|
|
|
- # state: started
|
|
|
- # enabled: yes # Ensure the MySQL service starts on boot
|
|
|
-
|
|
|
- # Store mariadb status in a variable
|
|
|
- # It'll be useful to conditionally run `/etc/init.d/mariadb setup`
|
|
|
- - name: Check MariaDB status
|
|
|
- command: service mariadb status
|
|
|
- register: mariadb_status
|
|
|
- ignore_errors: yes
|
|
|
-
|
|
|
- # # Echo 'MARIADB STARTED' if mariadb is running
|
|
|
- # - name: Debug MariaDB status
|
|
|
- # ansible.builtin.debug:
|
|
|
- # msg: "MARIADB STARTED"
|
|
|
- # when: mariadb_status.stdout.find('started') != -1
|
|
|
-
|
|
|
- # # Echo 'MARIADB STOPPED' if mariadb is NOT running
|
|
|
- # - name: Debug MariaDB status
|
|
|
- # ansible.builtin.debug:
|
|
|
- # msg: "MARIADB STOPPED"
|
|
|
- # when: mariadb_status.stdout.find('started') == -1
|
|
|
-
|
|
|
- # Problem I had: it failed here after 1st run
|
|
|
- # - name: MariaDB setup
|
|
|
- # command: /etc/init.d/mariadb setup
|
|
|
- # # run only if service is NOT running, that is, the output from
|
|
|
- # # `rc-service mariadb status` doesn't contain `started`
|
|
|
- # when: mariadb_status.stdout.find('started') == -1
|
|
|
+ - name: Start Nginx Service
|
|
|
+ ansible.builtin.service:
|
|
|
+ name: nginx
|
|
|
+ state: started
|
|
|
+ enabled: yes # Ensure the MySQL service starts on boot
|
|
|
|
|
|
- name: Start MariaDB Service
|
|
|
ansible.builtin.service:
|
|
|
@@ -116,12 +74,6 @@
|
|
|
state: started
|
|
|
enabled: yes # Ensure the MariaDB service starts on boot
|
|
|
|
|
|
- # On ne va pas le faire avec pip mais avec apt
|
|
|
- # - name: Install mysqlclient
|
|
|
- # ansible.builtin.pip:
|
|
|
- # name: mysqlclient
|
|
|
- # state: present
|
|
|
-
|
|
|
- name: Installer le client MySQL pour Python
|
|
|
ansible.builtin.apt:
|
|
|
name: python3-mysqldb
|