Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions ansible_step/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- hosts: lampstack
roles:
- wp
- mysql
4 changes: 4 additions & 0 deletions ansible_step/roles/mysql/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
wp_mysql_db: wordpress
wp_mysql_user: xpep
wp_mysql_password: xpepperWP
7 changes: 7 additions & 0 deletions ansible_step/roles/mysql/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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

4 changes: 4 additions & 0 deletions ansible_step/roles/wp/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- name: restart Apache
service: name=apache2 state=restarted
sudo: yes
23 changes: 23 additions & 0 deletions ansible_step/roles/wp/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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

16 changes: 16 additions & 0 deletions apt_step.sh
Original file line number Diff line number Diff line change
@@ -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