From edd809740428f8b88a2e759447d58a7252d318c8 Mon Sep 17 00:00:00 2001 From: valpenguin Date: Thu, 9 Feb 2017 23:04:45 +0100 Subject: [PATCH] Add files via upload --- Vagrantfile | 21 ++++++++++++++++++++ ansible_step/playbook.yml | 4 ++++ ansible_step/roles/mysql/defaults/main.yml | 4 ++++ ansible_step/roles/mysql/tasks/main.yml | 7 +++++++ ansible_step/roles/wp/handlers/main.yml | 4 ++++ ansible_step/roles/wp/tasks/main.yml | 23 ++++++++++++++++++++++ apt_step.sh | 16 +++++++++++++++ 7 files changed, 79 insertions(+) create mode 100644 Vagrantfile create mode 100644 ansible_step/playbook.yml create mode 100644 ansible_step/roles/mysql/defaults/main.yml create mode 100644 ansible_step/roles/mysql/tasks/main.yml create mode 100644 ansible_step/roles/wp/handlers/main.yml create mode 100644 ansible_step/roles/wp/tasks/main.yml create mode 100644 apt_step.sh diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..e4e2122 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,21 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/trusty64" + config.vm.network "public_network" + # Parte VBox + config.vm.provider "virtualbox" do |vb| + vb.memory = "2048" + end + # Parte bash + config.vm.define "lampstack" do|lampstack| + lampstack.vm.hostname = "lampstack" + lampstack.vm.provision :shell, path: "apt_step.sh" + end + # Parte Ansible (esegui un provision alla volta) + config.vm.provision :ansible do |ansible| + ansible.playbook = "ansible_step/playbook.yml" + end + +end diff --git a/ansible_step/playbook.yml b/ansible_step/playbook.yml new file mode 100644 index 0000000..bc629df --- /dev/null +++ b/ansible_step/playbook.yml @@ -0,0 +1,4 @@ +- hosts: lampstack + roles: + - wp + - mysql diff --git a/ansible_step/roles/mysql/defaults/main.yml b/ansible_step/roles/mysql/defaults/main.yml new file mode 100644 index 0000000..c2959fd --- /dev/null +++ b/ansible_step/roles/mysql/defaults/main.yml @@ -0,0 +1,4 @@ +--- +wp_mysql_db: wordpress +wp_mysql_user: xpep +wp_mysql_password: xpepperWP diff --git a/ansible_step/roles/mysql/tasks/main.yml b/ansible_step/roles/mysql/tasks/main.yml new file mode 100644 index 0000000..a367731 --- /dev/null +++ b/ansible_step/roles/mysql/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- name: Crea il DB mysql + mysql_db: name={{ wp_mysql_db }} state=present + +- name: Crea utente mysql + mysql_user: name={{ wp_mysql_user }} password={{ wp_mysql_password }} priv=*.*:ALL + diff --git a/ansible_step/roles/wp/handlers/main.yml b/ansible_step/roles/wp/handlers/main.yml new file mode 100644 index 0000000..5e24399 --- /dev/null +++ b/ansible_step/roles/wp/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: restart Apache + service: name=apache2 state=restarted + sudo: yes diff --git a/ansible_step/roles/wp/tasks/main.yml b/ansible_step/roles/wp/tasks/main.yml new file mode 100644 index 0000000..248230d --- /dev/null +++ b/ansible_step/roles/wp/tasks/main.yml @@ -0,0 +1,23 @@ +--- +- name: Scarico WordPress + get_url: url=https://it.wordpress.org/wordpress-4.7.2-it_IT.tar.gz dest=/tmp/wordpress.tar.gz validate_certs=no + sudo: yes +- name: Estrazione e spostamento + unarchive: src=/tmp/wordpress.tar.gz dest=/var/www/ copy=no + sudo: yes +- name: Update Apache + sudo: yes + lineinfile: dest=/etc/apache2/sites-enabled/000-default.conf regexp="(.)+DocumentRoot /var/www/html" line="DocumentRoot /var/www/wordpress" + notify: restart Apache + sudo: yes +- name: Copio il config file + command: mv /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php creates=/var/www/wordpress/wp-config.php + sudo: yes +- name: Modifica del config file + lineinfile: dest=/var/www/wordpress/wp-config.php regexp="{{ item.regexp }}" line="{{ item.line }}" + with_items: + - {'regexp': "define\\('DB_NAME', '(.)+'\\);", 'line': "define('DB_NAME', '{{wp_mysql_db}}');"} + - {'regexp': "define\\('DB_USER', '(.)+'\\);", 'line': "define('DB_USER', '{{wp_mysql_user}}');"} + - {'regexp': "define\\('DB_PASSWORD', '(.)+'\\);", 'line': "define('DB_PASSWORD', '{{wp_mysql_password}}');"} + sudo: yes + diff --git a/apt_step.sh b/apt_step.sh new file mode 100644 index 0000000..5eec0f4 --- /dev/null +++ b/apt_step.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# setup pacchetti stack LAMP, MySQL user root account +sudo apt-get -y update +sudo apt-get -y install apache2 +# Root di MySQL +sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password xpepper' +sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password xpepper' +# User MySQL per Vagrant +mysql -uroot -pxpepper -e "CREATE USER vagrant@localhost IDENTIFIED BY 'vagrant';" +echo "Utente Vagrant creato!" +mysql -uroot -pxpepper -e "GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'localhost';" +mysql -uroot -pxpepper -e "FLUSH PRIVILEGES;" +echo "Grant utente Vagrant ok!" +# Installo i pacchetti +sudo apt-get -y install mysql-server libapache2-mod-auth-mysql php5-mysql +sudo apt-get -y install php5 libapache2-mod-php5 php5-mcrypt php5-curl libssh2-php python-mysqldb