Roots Discourse

LXC/LXD as an alternative to Virtualbox for local development


#61

Sorry… realized it was a permissions issue. After setting the webroot permissions manually to 755 it works!


#62

For anyone else who is attempting this… I have two lxd profiles, one for my user setup and the second for specific dev site settings.

In the user profile I have included:

config:
  raw.idmap: |
    uid 1000 1000
    gid 1000 1000
  user.vendor-data: |
    #cloud-config
    users:
      - name: username
        groups: sudo
        shell: /bin/bash
        sudo: ['ALL=(ALL) NOPASSWD:ALL']
    # ensure users shell is installed
        packages:
          - bash
        ssh_authorized_keys:
          - ssh-rsa AA...etc...
description: users w-ssh +bridge
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: lxdbr0
    type: nic

and in the site specific one I have:

config:
  user.user-data: |
    #cloud-config
    package_upgrade: true
    hostname: example.test
    mangage_etc_hosts: true
    packages:
      - python-minimal
      - python-software-properties
      - build-essential
      - git
      - python-mysqldb
      - libnss-myhostname
      - dbus
      - python-pycurl
      - curl
    timezone: America/Vancouver
description: example dev profile
devices:
  root:
    path: /
    pool: default
    type: disk
  webroot:
    path: /srv/www/example.test/current
    source: /home/username/Websites/projects/example/site
    type: disk

Then launch the container:

lxc launch -p username -p example ubuntu:16.04 containername

Then:
lxc list for ip
add ip.address example.test to /etc/hosts

make sure you can ssh in:
ssh username@example.test

then run ansible playbook:
ansible-playbook -i hosts/development dev.yml -e env=development

Comments / Improvements welcome!