diff --git a/README.md b/README.md index 473631b..7cd716a 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,35 @@ Vagrant Centos 7 lamp using Ansible playbook ========================================= -[![Issues](https://img.shields.io/github/issues/skecskes/vagrant-centos7-ansible-lamp.svg?style=plastic)](https://github.com/skecskes/vagrant-centos7-ansible-lamp/issues) [![Forks](https://img.shields.io/github/forks/skecskes/vagrant-centos7-ansible-lamp.svg?style=plastic)](https://github.com/skecskes/vagrant-centos7-ansible-lamp/network) [![Stars](https://img.shields.io/github/stars/skecskes/vagrant-centos7-ansible-lamp.svg?style=plastic)](https://github.com/skecskes/vagrant-centos7-ansible-lamp/stargazers) [![License](https://img.shields.io/badge/license-GPLv2-blue.svg?style=plastic)](LICENSE) +[![Issues](https://img.shields.io/github/issues/skecskes/vagrant-centos7-ansible-lamp.svg?style=plastic)](https://github.com/skecskes/vagrant-centos7-ansible-lamp/issues) +[![Forks](https://img.shields.io/github/forks/skecskes/vagrant-centos7-ansible-lamp.svg?style=plastic)](https://github.com/skecskes/vagrant-centos7-ansible-lamp/network) +[![Stars](https://img.shields.io/github/stars/skecskes/vagrant-centos7-ansible-lamp.svg?style=plastic)](https://github.com/skecskes/vagrant-centos7-ansible-lamp/stargazers) +[![License](https://img.shields.io/badge/license-GPLv2-blue.svg?style=plastic)](LICENSE) -This personal development VM with Ansible provisioning is **fully working example**. I created this VM in order to have a proper php testbed for my php applications. After vagrant up, the main url will welcome you with phpinfo(). I hope you will enjoy this VM and I always accept recommendations and requests. +This personal development VM with Ansible provisioning is **fully working example**. I created this VM in order to +have a proper php testbed for my php applications. After vagrant up, the main url will welcome you with phpinfo(). +I hope you will enjoy this VM and I always accept recommendations and requests. ## Guest OS -I am using CentOS 7 x64 image from [somewhere](https://f0fff3908f081cb6461b407be80daf97f07ac418.googledrive.com/host/0BwtuV7VyVTSkUG1PM3pCeDJ4dVE/centos7.box) (thanks) +I am using the lastest CentOS 7 x64 image from official [Hashicorp](https://atlas.hashicorp.com/centos/7) (thanks) ## Prerequisites / Requirements -- virtualbox -- vagrant with guest additions (vagrant plugin install vagrant-vbguest) +- [Virtualbox platform](https://www.virtualbox.org/wiki/Downloads) +- [Vagrant](https://docs.vagrantup.com/v2/installation/) +- guest additions to Vagrant `vagrant plugin install vagrant-vbguest` +- [Git]() ## How to run +Create your new folder for your project. Clone this repository into that folder, which will download all configuration +needed to run vagrant machine. Then just run `vagrant up` in terminal and the rest will be done automatically. + +Note, that if you run it first time, vagrant will download the guest OS (414 MB of Centos 7 in this case) box +from internet, which in my case took 8 minutes and will save it locally so that you can use it later. + 1. open terminal 2. $ *cd /var/www* 3. $ *mkdir project* @@ -27,10 +40,19 @@ I am using CentOS 7 x64 image from [somewhere](https://f0fff3908f081cb6461b407be Your /var/www/project folder will be synced with with vagrants apache root directory. -## Includes +## What is included + +### Tag 1.0 - Apache 2.4.6 -- php 5.6.* -- mySql MariaDB 5.5.41 on port 3306 +- latest php 5.6.* +- latest mySQL MariaDB 5.5.* on port 3306 (user: root, pass: toor) - phpinfo() on http://10.0.0.10 - phpmyadmin on http://10.0.0.10:9000 (latest version is cloned into vagrantbox) + + +### Tag 2.0 + +Same as previous, but latest PHP 7.0.* (php7) is used + +![php7](ansible/roles/php70/php7.png) \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile index 0959404..b01f817 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,8 +1,7 @@ VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - config.vm.box = "centos-7" - config.vm.box_url = "https://f0fff3908f081cb6461b407be80daf97f07ac418.googledrive.com/host/0BwtuV7VyVTSkUG1PM3pCeDJ4dVE/centos7.box" + config.vm.box = "centos/7" config.vm.hostname = "vagrantbox" config.vm.network :forwarded_port, host: 80, guest: 80, auto_correct: true # website @@ -10,9 +9,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.network :forwarded_port, guest: 3306, host: 3306, auto_correct: true # mysql config.vm.network :forwarded_port, guest: 9000, host: 9000, auto_correct: true # phpmyadmin config.vm.network :private_network, ip: "10.0.0.10" - config.vm.synced_folder "./", "/var/www/html", id: "vagrant", :nfs => false, :mount_options => ["dmode=777", "fmode=666"] + config.vm.synced_folder "./", "/var/www/html", type: "rsync", id: "vagrant", :nfs => false, + :mount_options => ["dmode=777", "fmode=666"] config.vm.provider "virtualbox" do |vb| + vb.gui = false vb.customize ['modifyvm', :id, '--memory', '1024'] vb.customize ["modifyvm", :id, "--cpus", "1"] vb.customize ["modifyvm", :id, "--nictype1", "virtio"] diff --git a/ansible/playbook.yml b/ansible/playbook.yml index 56eb59b..c930740 100755 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -1,10 +1,11 @@ -# file: roles/playbook.yml +# file: ansible/playbook.yml --- - hosts: all roles: - init - httpd - - php56 + #- php56 + - php70 - mysql - phpmyadmin diff --git a/ansible/roles/httpd/handlers/main.yml b/ansible/roles/httpd/handlers/main.yml new file mode 100644 index 0000000..960ff71 --- /dev/null +++ b/ansible/roles/httpd/handlers/main.yml @@ -0,0 +1,5 @@ +# file: roles/httpd/handlers/main.yml +--- + +- name: restart httpd + service: name=httpd state=restarted \ No newline at end of file diff --git a/ansible/roles/init/handlers/main.yml b/ansible/roles/init/handlers/main.yml new file mode 100644 index 0000000..249522a --- /dev/null +++ b/ansible/roles/init/handlers/main.yml @@ -0,0 +1,5 @@ +# file: roles/php56/handlers/main.yml +--- + +- name: restart iptables + service: name=iptables state=restarted \ No newline at end of file diff --git a/ansible/roles/init/tasks/main.yml b/ansible/roles/init/tasks/main.yml index 63eb0c7..4454a6f 100644 --- a/ansible/roles/init/tasks/main.yml +++ b/ansible/roles/init/tasks/main.yml @@ -5,9 +5,18 @@ shell: systemctl enable firewalld shell: systemctl start firewalld +- name: Update Yum + yum: name=* state=latest + - name: Install nano, git, etc yum: pkg={{ item }} state=installed with_items: - git - nano - - curl \ No newline at end of file + - curl + - gcc + - kernel-devel + - wget + - vim + - man + - unzip \ No newline at end of file diff --git a/ansible/roles/php56/defaults/main.yml b/ansible/roles/php56/defaults/main.yml index 0b990e5..e473297 100644 --- a/ansible/roles/php56/defaults/main.yml +++ b/ansible/roles/php56/defaults/main.yml @@ -1,4 +1,4 @@ -# file: roles/php/defaults/main.yml +# file: roles/php56/defaults/main.yml --- composer_path: /usr/local/bin/composer diff --git a/ansible/roles/php56/handlers/main.yml b/ansible/roles/php56/handlers/main.yml index a2d174e..27bee73 100644 --- a/ansible/roles/php56/handlers/main.yml +++ b/ansible/roles/php56/handlers/main.yml @@ -1,8 +1,5 @@ -# file: roles/php/handlers/main.yml +# file: roles/php56/handlers/main.yml --- -- name: restart iptables - service: name=iptables state=restarted -- name: restart httpd - service: name=httpd state=restarted \ No newline at end of file + diff --git a/ansible/roles/php56/tasks/configure.yml b/ansible/roles/php56/tasks/configure.yml index d74df19..00dcd0d 100644 --- a/ansible/roles/php56/tasks/configure.yml +++ b/ansible/roles/php56/tasks/configure.yml @@ -1,4 +1,4 @@ -# file: roles/php/tasks/configure.yml +# file: roles/php56/tasks/configure.yml - name: Install Composer globally shell: curl -sS https://getcomposer.org/installer | /usr/bin/php && /bin/mv -f composer.phar {{ composer_path }} creates={{ composer_path }} diff --git a/ansible/roles/php56/tasks/install.yml b/ansible/roles/php56/tasks/install.yml index 31f5cdd..aad7539 100644 --- a/ansible/roles/php56/tasks/install.yml +++ b/ansible/roles/php56/tasks/install.yml @@ -1,4 +1,4 @@ -# file: roles/php/tasks/install.yml +# file: roles/php56/tasks/install.yml - name: Install epel from remote repo yum: name=http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm state=present @@ -9,13 +9,13 @@ - name: upgrade all packages yum: name=* state=latest -- name: Instal php +- name: Install php yum: pkg={{ item }} enablerepo=remi,remi-php56 state=present with_items: - php - php-common -- name: Instal php modules +- name: Install php modules yum: pkg={{ item }} enablerepo=remi,remi-php56 state=present with_items: - php-pecl-apcu diff --git a/ansible/roles/php56/tasks/main.yml b/ansible/roles/php56/tasks/main.yml index 686e549..af7847b 100644 --- a/ansible/roles/php56/tasks/main.yml +++ b/ansible/roles/php56/tasks/main.yml @@ -1,4 +1,4 @@ -# file: roles/php/tasks/main.yml +# file: roles/php56/tasks/main.yml --- - include: install.yml diff --git a/ansible/roles/php70/defaults/main.yml b/ansible/roles/php70/defaults/main.yml new file mode 100644 index 0000000..cc0f4c4 --- /dev/null +++ b/ansible/roles/php70/defaults/main.yml @@ -0,0 +1,4 @@ +# file: roles/php70/defaults/main.yml +--- + +composer_path: /usr/local/bin/composer diff --git a/ansible/roles/php70/handlers/main.yml b/ansible/roles/php70/handlers/main.yml new file mode 100644 index 0000000..7e2eca6 --- /dev/null +++ b/ansible/roles/php70/handlers/main.yml @@ -0,0 +1,8 @@ +# file: roles/php70/handlers/main.yml +--- + +- name: restart iptables + service: name=iptables state=restarted + +- name: restart httpd + service: name=httpd state=restarted \ No newline at end of file diff --git a/ansible/roles/php70/php7.png b/ansible/roles/php70/php7.png new file mode 100644 index 0000000..ef6ec1f Binary files /dev/null and b/ansible/roles/php70/php7.png differ diff --git a/ansible/roles/php70/tasks/configure.yml b/ansible/roles/php70/tasks/configure.yml new file mode 100644 index 0000000..451ba82 --- /dev/null +++ b/ansible/roles/php70/tasks/configure.yml @@ -0,0 +1,5 @@ +# file: roles/php70/tasks/configure.yml + +- name: Install Composer globally + shell: curl -sS https://getcomposer.org/installer | /usr/bin/php && /bin/mv -f composer.phar {{ composer_path }} creates={{ composer_path }} + diff --git a/ansible/roles/php70/tasks/install.yml b/ansible/roles/php70/tasks/install.yml new file mode 100644 index 0000000..d04f0cd --- /dev/null +++ b/ansible/roles/php70/tasks/install.yml @@ -0,0 +1,31 @@ +# file: roles/php70/tasks/install.yml + +- name: Install epel from remote repo + yum: name=https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm state=present + +- name: Install remi from remote repo + yum: name=http://rpms.remirepo.net/enterprise/remi-release-7.rpm state=present + +- name: upgrade all packages + yum: name=* state=latest + +- name: Install php + yum: pkg={{ item }} enablerepo=remi,remi-php70 state=present + with_items: + - php + +- name: Install php modules + yum: pkg={{ item }} enablerepo=remi,remi-php70 state=present + with_items: + - php-mbstring + - php-devel + - php-opcache + - php-soap + - php-pdo + - php-mcrypt + - php-pecl-xdebug + - php-xml + - php-mysql + - php-gd + notify: + - restart httpd \ No newline at end of file diff --git a/ansible/roles/php70/tasks/main.yml b/ansible/roles/php70/tasks/main.yml new file mode 100644 index 0000000..fa40e74 --- /dev/null +++ b/ansible/roles/php70/tasks/main.yml @@ -0,0 +1,5 @@ +# file: roles/php70/tasks/main.yml +--- + +- include: install.yml +- include: configure.yml \ No newline at end of file