Resources attached to the Road To DevOps tutorial
https://blog.noobtoroot.xyz/road-to-devops/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.2 KiB
1.2 KiB
TP Structures de contrôle
Utiliser les boucles pour :
-
gérer l'installation des packages,
-
effectuer les modifications sur le fichier de configuration de Wordpress.
Installation des packages avec loop
- name: Install packages
yum:
name: "{{ item }}"
state: present
loop:
- php
- php-mysql
- httpd
Ou en passant une liste au module yum
- name: Install packages
yum:
name:
- php
- php-mysql
- httpd
state: present
Configuration de Wordpress avec loop
- name: Create wordpress configuration file
copy:
src: /var/www/html/wordpress/wp-config-sample.php
dest: /var/www/html/wordpress/wp-config.php
remote_src: true
- name: Update wordpress configuration file
replace:
path: /var/www/html/wordpress/wp-config.php
regexp: "{{ item.regexp }}"
replace: "{{ item.replace }}"
loop:
- { regexp: 'database_name_here', replace: '{{ DB_NAME }}'}
- { regexp: 'username_here', replace: '{{ DB_USER }}'}
- { regexp: 'password_here', replace: '{{ DB_PASSWORD }}'}
- { regexp: 'localhost', replace: '{{ DB_HOST }}'}