Last active
November 6, 2020 22:09
-
-
Save raulunzue/3701fb2bdfa1c5fdbc07de09cb4048b7 to your computer and use it in GitHub Desktop.
Ansible: Instalación de Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Entrada El Blog de Negu: https://www.maquinasvirtuales.eu/ansible-crear-pagina-web-wordpress/ | |
- name: Ansible Wordpress | |
hosts: wordpress | |
become: yes | |
vars: | |
wp_mysql_db: wordpress | |
wp_mysql_user: wp-admin | |
wp_mysql_password: elblogdenegu | |
wp_mysql_host: "{{ansible_default_ipv4.address}}" | |
tasks: | |
- name: Instalacion LAMP Stack | |
yum: name={{ item }} state=present | |
with_items: | |
- httpd | |
- mysql-server | |
- php56 | |
- php-mysqlnd | |
- MySQL-python27 | |
- name: Borrar pagina de bienvenida en httpd | |
file: | |
path: "/etc/httpd/conf.d/welcome.conf" | |
state: absent | |
- name: Descarga de Wordpress | |
unarchive: | |
src: http://www.wordpress.org/latest.tar.gz | |
dest: /var/www/html/ | |
remote_src: yes | |
- name: Renombrar fichero de configuracion de ejemplo | |
command: "mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php" | |
- name: Modificamos valores fichero wp-config.php | |
lineinfile: dest=/var/www/html/wordpress/wp-config.php regexp={{ item.regexp }} line={{ item.line }} | |
with_items: | |
- {'regexp': "define\\( 'DB_NAME', '(database_name_here)+' \\);", 'line': "define('DB_NAME', '{{wp_mysql_db}}');"} | |
- {'regexp': "define\\( 'DB_USER', '(username_here)+' \\);", 'line': "define('DB_USER', '{{wp_mysql_user}}');"} | |
- {'regexp': "define\\( 'DB_PASSWORD', '(password_here)+' \\);", 'line': "define('DB_PASSWORD', '{{wp_mysql_password}}');"} | |
- {'regexp': "define\\( 'DB_HOST', '(localhost)+' \\);", 'line': "define('DB_HOST', '{{wp_mysql_host}}');"} | |
- name: Actualizamos configuracion Apache | |
lineinfile: | |
dest=/etc/httpd/conf/httpd.conf | |
line="DocumentRoot /var/www/html/wordpress" | |
- name: Arrancamos mysql | |
service: | |
name: mysqld | |
state: started | |
- name: Creamos la base de datos | |
mysql_db: | |
name: "{{wp_mysql_db}}" | |
login_unix_socket: /run/mysqld/mysqld.sock | |
state: present | |
- name: Creamos usuario de gestión BD | |
mysql_user: | |
name: "{{wp_mysql_user}}" | |
password: "{{wp_mysql_password}}" | |
host: '%' | |
priv: '*.*:ALL' | |
state: present | |
- name: Arrancamos httpd y mysql | |
service: name={{ item }} state=restarted | |
with_items: | |
- httpd | |
- mysqld | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment