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.

37 lines
776 B

## TP Structures de contrôle
Utiliser un fichier template pour effectuer la configuration de Wordpress.
`templates/wp-config.php.j2`
```php
<?php
...
define('DB_NAME', '{{ dbname }}');
define('DB_USER', '{{ dbuser }}');
define('DB_PASSWORD', '{{ dbpassword }}');
define('DB_HOST', '{{ dbhost }}');
...
```
<!-- .slide: data-state="medium-code" -->
```yaml
- hosts: web
vars:
dbname: wordpress
dbuser: wordpressuser
dbpassword: wpassword
dbhost: localhost
tasks:
- name: Deploy wordpress config
template:
src: templates/wp-config.php.j2
dest: /var/www/html/wordpress/wp-config.php
owner: apache
group: apache
mode: 0600
```
Les variables sont automatiquement injectées dans le fichier sur la cible.