-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from cakephp/add-vagrant
Add vagrantfile and some sample data
- Loading branch information
Showing
28 changed files
with
743 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,28 @@ the [bookmarker tutorial](http://book.cakephp.org/3.0/en/quickstart.html). | |
5. Configure your database credentials in ``app.php``. Make sure to use the same database name as in step 4. | ||
6. Start the server `bin/cake server -p 8765`. | ||
7. Go to http://localhost:8765 in your browser. | ||
|
||
# Using Vagrant | ||
|
||
If you don't have a local development environment setup, you can use Vagrant to | ||
create one. After installing Vagrant run: | ||
|
||
``` | ||
vagrant up | ||
``` | ||
|
||
This will download a new vagrant image, and run ansible to provision the | ||
bookmarking application. Once ansible is complete, you should have a working | ||
application available at http://192.168.33.99 . | ||
|
||
### Logging In | ||
|
||
You can login to the application at http://192.168.33.99/users/login. The | ||
username is `[email protected]` and the password is `password`. | ||
|
||
## Before you run Ansible a second time | ||
|
||
After the initial provisioning run if you want to re-run ansible, make sure to | ||
remove `mysql.dump` in `ansible/vars/all.yml` or ansible will reset your | ||
database state to whats in the SQL dump file. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
################################################## | ||
# Generated by phansible.com | ||
################################################## | ||
|
||
#If your Vagrant version is lower than 1.5, you can still use this provisioning | ||
#by commenting or removing the line below and providing the config.vm.box_url parameter, | ||
#if it's not already defined in this Vagrantfile. Keep in mind that you won't be able | ||
#to use the Vagrant Cloud and other newer Vagrant features. | ||
Vagrant.require_version ">= 1.5" | ||
|
||
# Check to determine whether we're on a windows or linux/os-x host, | ||
# later on we use this to launch ansible in the supported way | ||
# source: https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby | ||
def which(cmd) | ||
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] | ||
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| | ||
exts.each { |ext| | ||
exe = File.join(path, "#{cmd}#{ext}") | ||
return exe if File.executable? exe | ||
} | ||
end | ||
return nil | ||
end | ||
|
||
Vagrant.configure("2") do |config| | ||
|
||
config.vm.provider :virtualbox do |v| | ||
v.name = "bookmarker" | ||
v.customize [ | ||
"modifyvm", :id, | ||
"--name", "bookmarker", | ||
"--memory", 512, | ||
"--natdnshostresolver1", "on", | ||
"--cpus", 1, | ||
] | ||
end | ||
|
||
config.vm.box = "ubuntu/trusty64" | ||
|
||
config.vm.network :private_network, ip: "192.168.33.99" | ||
config.ssh.forward_agent = true | ||
|
||
# If ansible is in your path it will provision from your HOST machine | ||
# If ansible is not found in the path it will be instaled in the VM and provisioned from there | ||
if which('ansible-playbook') | ||
config.vm.provision "ansible" do |ansible| | ||
ansible.playbook = "ansible/playbook.yml" | ||
ansible.inventory_path = "ansible/inventories/dev" | ||
ansible.limit = 'all' | ||
end | ||
else | ||
config.vm.provision :shell, path: "ansible/windows.sh", args: ["default"] | ||
end | ||
|
||
config.vm.synced_folder "./", "/vagrant", type: "nfs" | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[phansible-web] | ||
192.168.33.99 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- hosts: all | ||
sudo: true | ||
vars_files: | ||
- vars/all.yml | ||
roles: | ||
- server | ||
- vagrant_local | ||
- apache | ||
- mysql | ||
- php | ||
- composer | ||
- app |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- name: restart apache | ||
service: name=apache2 enabled=yes state=restarted |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: Install Apache | ||
sudo: yes | ||
apt: pkg=apache2 state=latest | ||
|
||
- name: Install Apache Modules | ||
apache2_module: state=present name={{ item }} | ||
notify: restart apache | ||
with_items: | ||
- rewrite | ||
- vhost_alias | ||
- headers | ||
- expires | ||
- filter | ||
|
||
- shell: apache2 -v | ||
register: apache_version | ||
|
||
- name: Change default apache2.4 site | ||
sudo: yes | ||
template: src=vhost24.conf.tpl dest=/etc/apache2/sites-available/000-default.conf | ||
notify: restart apache | ||
when: apache_version.stdout.find('Apache/2.4.') != -1 | ||
|
||
- name: Change default apache2.2 site | ||
sudo: yes | ||
template: src=vhost22.conf.tpl dest=/etc/apache2/sites-available/default | ||
notify: restart apache | ||
when: apache_version.stdout.find('Apache/2.2.') != -1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Default Apache virtualhost template | ||
|
||
<VirtualHost *:80> | ||
ServerAdmin webmaster@localhost | ||
DocumentRoot {{ apache.docroot }} | ||
ServerName {{ apache.servername }} | ||
|
||
<Directory {{ apache.docroot }}> | ||
AllowOverride All | ||
Options -Indexes FollowSymLinks | ||
Order allow,deny | ||
Allow from all | ||
</Directory> | ||
</VirtualHost> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Default Apache virtualhost template | ||
|
||
<VirtualHost *:80> | ||
ServerAdmin webmaster@localhost | ||
DocumentRoot {{ apache.docroot }} | ||
ServerName {{ apache.servername }} | ||
|
||
<Directory {{ apache.docroot }}> | ||
AllowOverride All | ||
Options -Indexes +FollowSymLinks | ||
Require all granted | ||
</Directory> | ||
</VirtualHost> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: Create web app config file. | ||
template: | ||
args: | ||
src: app.php.tpl | ||
dest: "/vagrant/config/app.php" | ||
|
||
- name: Install composer dependencies | ||
command: "composer install --no-interactive" | ||
args: | ||
creates: "/vagrant/vendor/autoload.php" | ||
chdir: "/vagrant" |
Oops, something went wrong.