Skip to content

ziadoz/arthur

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arthur

A virtual machine environment for web development.

Usage

Install the latest versions of the following:

After installing Homebrew you can quickly install the other dependencies:

brew install ansible ansible-lint packer
brew cask install vagrant virtualbox virtualbox-extension-pack

Now run the following command: vagrant up.

Host Commands

Build the box using Packer:

(cd packer && packer build --force template.json)

Bring up the virtual machine:

vagrant up

Remove SSH key:

ssh-keygen -R 192.168.33.42

Start up headless Chrome and Selenium (IP address whitelist is import to connect host to guest):

chromedriver --url-base=/wd/hub --whitelisted-ips=''

Access MailHog at http://192.168.33.42:1025

Guest Commands

Start up headless Chrome and Selenium:

chromedriver --url-base=/wd/hub

Removing all virtualhost configurations:

rmsites

Symlinking a virtualhost configuration in the current directory:

lnsite
lnsite foo.conf
lnsite *-foo.conf

Run versions to list the installed software.

Debug Commands

Lint the playbook:

ansible-lint ansible/playbook.yml

Validate the playbook:

ansible-playbook ansible/playbook.yml --syntax-check

Install the required roles:

ansible-galaxy install -r ansible/requirements.yml

Ping the inventory:

ansible all -m ping

Get facts about the inventory:

ansible all -m setup -v
ansible all -m setup -v > facts.json

Run tasks by tag:

ansible-playbook ansible/playbook.yml --tags "foo,bar"
ansible-playbook ansible/playbook.yml --skip-tags "foo,bar"

Run tasks with extra variables:

ansible-playbook ansible/playbook.yml --extra-vars="user_account=foobar"

Run playbook on production:

ansible-playbook ansible/playbook.yml --ask-become-pass --limit production
ansible-playbook ansible/playbook.yml --ask-become-pass --limit production --tags user

Debug a playbook:

ansible-playbook -i 192.168.33.42, --user=vagrant --private-key=~/Projects/arthur/vagrant/.vagrant/machines/default/virtualbox/private_key --ssh-common-args="-o StrictHostKeyChecking=no" ansible/playbook.yml

To fix macOS Mojave Python issus:

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

To provision the virtual machine for further development, add these lines to Vagrantfile:

# Provision Debugging
config.vm.box = "bento/ubuntu-18.04"
config.vm.provision :ansible do |ansible|
    ansible.inventory_path = "inventory"
    ansible.playbook       = "ansible/playbook.yml"
    ansible.limit          = "development"
    ansible.verbose        = true
end

And then provision the VM:

vagrant provision

In order to access Go web applications the ports will need to be opened in UFW:

sudo ufw allow 8080

You can make daily usage easier with this handy alias:

function arthur() {
    (cd ~/Projects/arthur && vagrant $*)
}

Future Improvements

Potential improves and ideas to improve Arthur:

  • Remove non-development bits (firewall, SSH configuration, inventory groups, idempotent bits like Composer and Go). ***
  • Move configuration of PHP, MySQL, Bash, etc. to an init provisioner in Vagrant,so it can easily be reloaded. ***
  • Switch permissions to u=rwx,g=rwx,o=rwx format.
  • Use an Ansible vault to store passwords and settings.
  • Store packaged boxes on cloud storage (Dropbox, Google Drive).
  • Add /etc/hosts file with domains in for projects so internal requests resolve.
  • Overhaul the README.md and make improvements.

Software

Software to consider adding in the future:

Alternatives

Alternatives to this VM, mostly for reference:

Links

Links that have been useful for development and debugging.