Update based on OVN learning environment

Update Vagrantfile, Ansible playbook (provision.yml), and machines.yml based on "plain" OVN learning environment

Signed-off-by: Scott S. Lowe <scott.lowe@scottlowe.org>
This commit is contained in:
Scott S. Lowe 2016-12-05 22:40:02 -07:00
parent 70bb2e959e
commit d581dba3a8
4 changed files with 87 additions and 44 deletions

View file

@ -31,7 +31,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
srv.vm.hostname = machine['name']
# Specify the Vagrant box to use (use VMware box by default)
srv.vm.box = machine['vmw_box']
srv.vm.box = machine['box']['vmw']
# Configure default synced folder (disable by default)
if machine['sync_disabled'] != nil
@ -40,10 +40,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
srv.vm.synced_folder '.', '/vagrant', disabled: true
end #if machine['sync_disabled']
# Assign additional private network
if machine['ip_addr'] != nil
srv.vm.network 'private_network', ip: machine['ip_addr']
end # if machine['ip_addr']
# Iterate through networks as per settings in machines.yml
machine['nics'].each do |net|
if net['ip_addr'] == 'dhcp'
srv.vm.network net['type'], type: net['ip_addr']
else
srv.vm.network net['type'], ip: net['ip_addr']
end # if net['ip_addr']
end # machine['nics'].each
# Configure CPU & RAM per settings in machines.yml (Fusion)
srv.vm.provider 'vmware_fusion' do |vmw|
@ -58,7 +62,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
srv.vm.provider 'virtualbox' do |vb, override|
vb.memory = machine['ram']
vb.cpus = machine['vcpu']
override.vm.box = machine['vb_box']
override.vm.box = machine['box']['vb']
vb.customize ['modifyvm', :id, '--nictype1', 'virtio']
vb.customize ['modifyvm', :id, '--nictype2', 'virtio']
end # srv.vm.provider 'virtualbox'
@ -67,6 +71,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Provision the VM with Ansible
config.vm.provision 'ansible' do |ansible|
ansible.playbook = 'update.yml'
ansible.playbook = 'provision.yml'
end # config.vm.provision
end # Vagrant.configure

View file

@ -3,7 +3,7 @@
{% set quote = '"' %}
{
"advertise_addr": "{{ hostvars[inventory_hostname]['ansible_eth1']['ipv4']['address'] }}",
"advertise_addr": "{{ hostvars[inventory_hostname]['ansible_enp0s8']['ipv4']['address'] }}",
"bootstrap_expect": 3,
"client_addr": "0.0.0.0",
"datacenter": "dc1",
@ -11,9 +11,9 @@
"enable_syslog": true,
"log_level": "INFO",
"retry_join": [ {% for host in groups['all'] %}{% if not loop.last %}
"{{ hostvars[host]['ansible_eth1']['ipv4']['address'] }}",
"{{ hostvars[host]['ansible_enp0s8']['ipv4']['address'] }}",
{% else %}
"{{ hostvars[host]['ansible_eth1']['ipv4']['address'] }}"
"{{ hostvars[host]['ansible_enp0s8']['ipv4']['address'] }}"
{% endif %}{% endfor %} ],
"server": true
}

View file

@ -1,19 +1,28 @@
---
- name: "docker-01"
vmw_box: "slowe/ubuntu-trusty-x64"
vb_box: "ubuntu/trusty64"
- box:
vmw: "bento/ubuntu-16.04"
vb: "bento/ubuntu-16.04"
name: "docker-01"
nics:
- type: "private_network"
ip_addr: "192.168.100.101"
ram: "512"
vcpu: "1"
ip_addr: "192.168.100.101"
- name: "docker-02"
vmw_box: "slowe/ubuntu-trusty-x64"
vb_box: "ubuntu/trusty64"
- box:
vmw: "bento/ubuntu-16.04"
vb: "bento/ubuntu-16.04"
name: "docker-02"
nics:
- type: "private_network"
ip_addr: "192.168.100.102"
ram: "512"
vcpu: "1"
ip_addr: "192.168.100.102"
- name: "docker-03"
vmw_box: "slowe/ubuntu-trusty-x64"
vb_box: "ubuntu/trusty64"
- box:
vmw: "bento/ubuntu-16.04"
vb: "bento/ubuntu-16.04"
name: "docker-03"
nics:
- type: "private_network"
ip_addr: "192.168.100.103"
ram: "512"
vcpu: "1"
ip_addr: "192.168.100.103"

View file

@ -18,6 +18,7 @@
- "git"
- "libtool"
- "autoconf"
- "ubuntu-cloud-keyring"
tags:
- consul
- packages
@ -57,15 +58,15 @@
- name: Download Consul package
get_url:
url: "https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_linux_amd64.zip"
dest: "/tmp/consul_0.7.0_linux_amd64.zip"
url: "https://releases.hashicorp.com/consul/0.7.1/consul_0.7.1_linux_amd64.zip"
dest: "/tmp/consul_0.7.1_linux_amd64.zip"
tags:
- consul
- name: Unzip downloaded Consul file
unarchive:
copy: "no"
src: "/tmp/consul_0.7.0_linux_amd64.zip"
src: "/tmp/consul_0.7.1_linux_amd64.zip"
dest: "/usr/local/bin/"
creates: "/usr/local/bin/consul"
tags:
@ -107,20 +108,12 @@
- docker
- apt-cfg
- name: Add Docker APT repository (Trusty)
- name: Add Docker APT repository (Xenial)
apt_repository:
repo: "deb https://apt.dockerproject.org/repo ubuntu-trusty main"
repo: "deb https://apt.dockerproject.org/repo ubuntu-xenial main"
update_cache: "yes"
state: "present"
when: ansible_distribution_release == "trusty"
tags:
- docker
- apt-cfg
- name: Add Docker APT repository (Precise)
apt_repository:
repo: "deb https://apt.dockerproject.org/repo ubuntu-precise main"
state: "present"
when: ansible_distribution_release == "precise"
when: ansible_distribution_release == "xenial"
tags:
- docker
- apt-cfg
@ -132,7 +125,7 @@
update_cache: "yes"
cache_valid_time: "3600"
with_items:
- "docker-engine=1.11.2-0~trusty"
- "docker-engine=1.11.2-0~xenial"
tags:
- docker
- packages
@ -141,7 +134,7 @@
lineinfile:
dest: "/etc/default/docker"
insertafter: '#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"'
line: "DOCKER_OPTS='-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store=consul://127.0.0.1:8500 --cluster-advertise={{ ansible_eth1.ipv4.address }}:0'"
line: "DOCKER_OPTS='-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store=consul://127.0.0.1:8500 --cluster-advertise={{ ansible_enp0s8.ipv4.address }}:0'"
owner: "root"
group: "root"
mode: "0644"
@ -176,10 +169,47 @@
- docker
- ovn
- name: Download OVS 2.6.0 release tarball
become: "no"
get_url:
url: "https://github.com/openvswitch/ovs/archive/v2.6.0.tar.gz"
dest: "/home/vagrant/2.6.0.tar.gz"
- name: "Add Ubuntu Cloud Archive repository"
apt_repository:
repo: "{{ item }}"
state: "present"
update_cache: "yes"
with_items:
- "deb http://ubuntu-cloud.archive.canonical.com/ubuntu xenial-updates/newton main"
tags:
- ovn
- apt-cfg
- name: "Install OVS/OVN 2.6.0"
apt:
state: "present"
update_cache: "no"
name: "{{ item }}"
with_items:
- "ovn-common"
- "ovn-host"
- "openvswitch-common"
- "openvswitch-switch"
tags:
- ovn
- packages
- name: "Install central OVN components"
apt:
state: "present"
update_cache: "no"
name: "ovn-central"
when: ansible_hostname == "docker-01"
tags:
- ovn
- packages
- name: "Install configuration script"
template:
src: "setup.sh.j2"
dest: "/home/vagrant/setup.sh"
owner: "vagrant"
group: "vagrant"
mode: "0755"
tags:
- ovn