diff --git a/tools/vagrant_dev_env/Vagrantfile b/tools/vagrant_dev_env/Vagrantfile index cc1de5558..102d1631c 100644 --- a/tools/vagrant_dev_env/Vagrantfile +++ b/tools/vagrant_dev_env/Vagrantfile @@ -5,9 +5,11 @@ VAGRANTFILE_API_VERSION = '2' ansible_install_root=(ENV['ANSIBLE_INSTALL_ROOT'] || "/opt/stack") Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + config.vm.box = 'generic/ubuntu1804' - config.vm.box = 'ubuntu/trusty64' - + config.vm.provider "libvirt" do |lv| + lv.cpu_mode = 'host-passthrough' + end config.vm.define 'bifrost' do |bifrost| bifrost.vm.provider :virtualbox do |vb| vb.customize ['modifyvm', :id, '--memory', '8196', '--cpus', '4'] @@ -19,21 +21,34 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| vb.customize ["modifyvm", :id, "--nictype3", "Am79C973"] end + bifrost.vm.provider "libvirt" do |lv| + lv.memory = 8196 + lv.cpus = 2 + lv.nested = true + lv.volume_cache = 'none' + end + # If ANSIBLE_INSTALL_ROOT is available, set that value inside the VM if ENV['ANSIBLE_INSTALL_ROOT'] bifrost.vm.provision "shell", inline: <<-SHELL echo "export ANSIBLE_INSTALL_ROOT=#{ENV['ANSIBLE_INSTALL_ROOT']}" >> /etc/profile.d/ansible-root.sh + echo "if [ \"$IFACE\" = \"eth0\" ]; then route del default dev eth0 ; fi" >> /etc/network/if-up.d + echo "[Match]\nName=eth0\n[Network]\nDHCP=yes\n[DHCP]\nUseRoutes=false" >>/etc/systemd/network/no-default-route.network SHELL end # Set up private NAT'd network - bifrost.vm.network 'private_network', ip: '192.168.99.10' # it goes to 11 + bifrost.vm.network 'private_network', ip: '192.168.99.10', use_dhcp_assigned_default_route: false + # This assumes you have DHCP on your bridged network. if not you will need # to statically configure to allow Bifrost to manage hardware attached to # the bridged interface. # NOTE(TheJulia): Is there a way to abstract the bridged networking... # NOTE(NobodyCam): until the above is done this needs to be set to a valid interface - bifrost.vm.network 'public_network', bridge: '' + # NOTE(TheJulia): Virtualbox will ask you. libvirt won't and you need to use the dev + # field instead of bridge. + bifrost.vm.network "public_network", bridge: 'enp3s0', dev: 'enp3s0' + # besure we get the entire bifrost directory tree bifrost.vm.synced_folder "../../.", "/home/vagrant/bifrost", type: "rsync" @@ -49,7 +64,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # eth0 - connected to a Nat network # eth1 - connected to Host-only network named: 'vboxnet1' # eth2 - bridged - Interface must also be set above - network_interface: 'eth2' + network_interface: 'eth0' } end end diff --git a/tools/vagrant_dev_env/vagrant.yml b/tools/vagrant_dev_env/vagrant.yml index 1a4ca6fee..5994ba4f7 100644 --- a/tools/vagrant_dev_env/vagrant.yml +++ b/tools/vagrant_dev_env/vagrant.yml @@ -8,6 +8,12 @@ ############################################################################ # Install some reqired bits into the vm ############################################################################ + - name: Remove private default route + command: ip route del default dev eth0 + ignore_errors: true + #- name: trigger DHCP eth2 + # command: dhclient eth2 + # Make sure our VM's software is ~@Latest - name: Apt Update apt: update_cache=yes @@ -15,34 +21,31 @@ cache_valid_time=86400 when: ansible_distribution == 'Ubuntu' - - name: Make sure distro setuptools is not there - apt: name=python-setuptools state=absent - when: ansible_distribution == 'Ubuntu' - - - name: Download get-pip - get_url: url=https://bootstrap.pypa.io/get-pip.py - dest=/tmp/get-pip.py + # - name: Make sure distro setuptools is not there + # apt: name=python-setuptools state=absent + # when: ansible_distribution == 'Ubuntu' - name: Install pip - shell: python /tmp/get-pip.py + apt: name=python3-pip state=present + when: ansible_distribution == 'Ubuntu' - name: Install python-dev - apt: name=python-dev state=present + apt: name=python3-dev state=present when: ansible_distribution == 'Ubuntu' # these would also be installed by 'Prepare VM for Bifrost' # below As they are larger packages I think its worth installing # them on their own. - - name: Install erlang-base - apt: name=erlang-base state=present - when: ansible_distribution == 'Ubuntu' + #- name: Install erlang-base + # apt: name=erlang-base state=present + # when: ansible_distribution == 'Ubuntu' - name: Install Rabbit-Server apt: name=rabbitmq-server state=present when: ansible_distribution == 'Ubuntu' - name: Install MySql-Server - apt: name=mysql-server state=present + apt: name=mariadb-server state=present when: ansible_distribution == 'Ubuntu' # get ip for public_network @@ -51,10 +54,13 @@ register: guest_ip # Reboot if required. - - name: Reboot system if required - command: shutdown -r now 'Rebooting to complete system upgrade' - removes=/var/run/reboot-required - register: rebooted + # - name: Reboot system if required + # command: shutdown -r now 'Rebooting to complete system upgrade' + # removes=/var/run/reboot-required + # register: rebooted + # + # Systemd likes to do frustrating things with networking, so we need to + # wait a little bit. - name: Wait for VM Reboot. become: no local_action: wait_for @@ -63,7 +69,15 @@ search_regex=OpenSSH delay=10 timeout=900 - when: rebooted.changed + # when: rebooted.changed + + - name: make /root/.ssh folder + file: + path: /root/.ssh + state: directory + owner: root + group: root + mode: 0700 - name: Copy SSH public key into VM copy: src=~/.ssh/{{public_key}} dest=~/.ssh/id_rsa.pub @@ -78,11 +92,13 @@ command: scripts/env-setup.sh environment: ANSIBLE_INSTALL_ROOT: "{{ansible_install_root}}" + LANG: c args: chdir: /home/vagrant/bifrost + become: yes - name: Install Bifrost - command: ansible-playbook -vvvv -i inventory/localhost install.yaml -e network_interface={{network_interface}} + command: ansible-playbook -vvvv -i inventory/target install.yaml -e network_interface={{network_interface}} environment: PATH: "{{ansible_env.HOME}}/.local/bin:{{ansible_env.PATH}}" args: