This repository is a simple demonstration of a virtualized environment (vagrant + virtualbox), tailored for drupal, within a Centos 7x operating system. Specifically, a custom vagrant base box, has been created, from minimal iso, with a custom selinux policy module enabled. This allows the corresponding drupal website, within the specified document root, to be served up. The exact details of the vagrant box, can be located via the corresponding atlas repository.
Please adhere to contributing.md
, when contributing code. Pull requests that deviate from the
contributing.md
, could be labelled
as invalid
, and closed (without merging to master). These best practices
will ensure integrity, when revisions of code, or issues need to be reviewed.
This project implements puppet's r10k
module via vagrant's plugin. A
requirement of this implementation includes a Puppetfile
(already defined),
which includes the following syntax:
#!/usr/bin/env ruby
## Install Module: vcsrepo
mod 'vcsrepo',
:git => '[email protected]:puppetlabs/puppetlabs-vcsrepo.git',
:ref => '1.3.0'
...
Specifically, this implements the ssh syntax [email protected]:account/repo.git
,
unlike the following alternatives:
https://github.com/account/repo.git
git://github.com/account/repo.git
This allows r10k to clone the corresponding puppet module(s), without a deterrence of DDoS. However, to implement the above syntax, ssh keys need to be generated, and properly assigned locally, as well as on the github account.
The following steps through how to implement the ssh keys with respect to github:
$ cd ~/.ssh/
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
$ ssh-agent -s
Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
$ pbcopy < ~/.ssh/id_rsa.pub
Note: it is recommended to simply press enter, to keep default values
when asked Enter file in which to save the key. Also, if ssh-agent -s
alternative for git bash doesn't work, then eval $(ssh-agent -s)
for other
terminal prompts should work.
Then, at the top of any github page (after login), click Settings > SSH keys > Add SSH Keys
, then paste the above copied key into the Key
field, and click
Add key. Finally, to test the ssh connection, enter the following within
the same terminal window used for the above commands:
$ ssh -T [email protected]
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of
known hosts.
Hi jeff1evesque! You've successfully authenticated, but GitHub does not provide
shell access.
Fork this project in your GitHub account. Then, clone your repository, with one of the following approaches:
- simple clone: clone the remote master branch.
- commit hash: clone the remote master branch, then checkout a specific commit hash.
- release tag: clone the remote branch, associated with the desired release tag.
Then, remember to customize install.pp
:
...
$drupal_user = 'admin'
$drupal_pass = 'password'
$site_name = 'sample'
$site_email = '[email protected]'
$locale_val = 'us'
...
The above snippet will ensure a drupal admin
user, with a defined password
,
upon a successful drupal installation.
Similarly, the additional variables can be trivially defined.
cd /[destination-directory]
sudo git clone https://[account]@github.com/[account]/drupal-demonstration.git
cd drupal-demonstration
git remote add upstream https://github.com/[account]/drupal-demonstration.git
Note: [destination-directory]
corresponds to the desired directory path,
where the project repository resides. [account]
corresponds to the git
username, where the repository is being cloned from. If the original
repository was forked, then use your git username, otherwise, use
jeff1evesque
.
cd /[destination-directory]
sudo git clone https://[account]@github.com/[account]/drupal-demonstration.git
cd drupal-demonstration
git remote add upstream https://github.com/[account]/drupal-demonstration.git
# stop vagrant
vagrant halt
# ensure diffs don't prevent checkout, then checkout hash
git checkout -- .
git checkout [hash]
Note: the hashes associated with a release, can be found under the corresponding tag value, on the release page.
Note: [destination-directory]
corresponds to the desired directory path,
where the project repository resides. [account]
corresponds to the git
username, where the repository is being cloned from. If the original
repository was forked, then use your git username, otherwise, use
jeff1evesque
.
cd /[destination-directory]
# clone release tag: master branch does not exist
sudo git clone -b [release-tag] --single-branch --depth 1 https://github.com/[account]/drupal-demonstration.git [destination-directory]
git remote add upstream https://github.com/[account]/drupal-demonstration.git
# create master branch from remote master
cd drupal-demonstration
git checkout -b master
git pull upstream master
# return to release tag branch
git checkout [release-tag]
Note: [release-tag]
corresponds to the release tag
value, used to distinguish between releases.
Note: [destination-directory]
corresponds to the desired directory path,
where the project repository resides. [account]
corresponds to the git
username, where the repository is being cloned from. If the original
repository was forked, then use your git username, otherwise, use
jeff1evesque
.
In order to proceed with the installation for this project, two dependencies need to be installed:
- Vagrant
- Virtualbox (with extension pack)
Once the necessary dependencies have been installed, execute the following command to build the virtual environment:
cd /path/to/drupal-demonstration/
vagrant up
Depending on the network speed, the build can take between 10-15 minutes. So,
grab a cup of coffee, and perhaps enjoy a danish while the virtual machine
builds. Remember, the application is intended to run on localhost, where the
Vagrantfile
defines the exact port-forward on the host machine.
Note: a more complete refresher on virtualization, can be found within the vagrant wiki page.
The following lines, indicate the application is accessible via
https://localhost:6586
, on the host machine, since ssl has been configured:
...
## Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine.
config.vm.network "forwarded_port", guest: 80, host: 6585
config.vm.network "forwarded_port", guest: 443, host: 6686
...
Note: general convention implements port 443
for ssl.
When the vagrant up
build succeeds, the corresponding drupal installation
sample
profile, will have enabled corresponding drupal modules, and themes.
Additionally the database can be accessed via the following accounts:
- mariadb root:
root
- mariadb user:
authenticated
- mariadb pass (for both):
password
This project includes a fully functional phpMyAdmin implementation, which can be accessed as follows:
The corresponding user / password, is the same as our drupal mariadb implementation:
- mariadb user:
authenticated
- mariadb pass:
password
The following user / password, have been created:
root
:vagrant-admin
provisioner
:vagrant-provision
In addition, the ssh key-pair implements the passphrase:
passphrase
Several preconfigured drush scripts have been defined:
drush/core_update.py
: update drupal core, without rewritingwebroot/.htaccess
, andwebroot/robots.txt
.
To run one of the above drush scripts:
$ vagrant ssh
==> default: The machine you're attempting to SSH into is configured to use
==> default: password-based authentication. Vagrant can't script entering the
==> default: password for you. If you're prompted for a password, please enter
==> default: the same password you have configured in the Vagrantfile.
Enter passphrase for key '/path/to/.ssh/id_rsa':
[email protected]'s password:
Last login: Tue Feb xx xx:xx:xx xxxx from gateway
[provisioner@drupal-demonstration ~]$ cd /vagrant/drush
[provisioner@drupal-demonstration ~]$ python [script].py