Daniel Farrell
Software Engineer, Red Hat SDN Team
[~/vagrant-opendaylight]$ vagrant status
Current machine states:
cent7_pup_rpm not created (virtualbox)
cent7_ansible not created (virtualbox)
cent7_pup_tb not created (virtualbox)
cent7_rpm not created (virtualbox)
f20_pup_rpm not created (virtualbox)
f20_pup_tb not created (virtualbox)
f20_rpm not created (virtualbox)
f21_pup_rpm saved (virtualbox)
f21_pup_tb not created (virtualbox)
f21_rpm saved (virtualbox)
[~/sandbox]$ vagrant init -m centos/7
[~/sandbox]$ cat Vagrantfile
Vagrant.configure(2) do |config|
config.vm.box = "centos/7"
end
[~/sandbox]$ vagrant up
[~/sandbox]$ vagrant ssh
[vagrant@localhost ~]$
[vagrant@localhost ~]$ curl -o distribution-karaf-0.2.3-Helium-SR3.tar.gz \
<long tarball URL>
[vagrant@localhost ~]$ sudo mkdir /opt/opendaylight
[vagrant@localhost ~]$ sudo tar -x
--strip-components=1
--directory=/opt/opendaylight
-f <long tarball name>
[vagrant@localhost ~]$ sudo /opt/opendaylight/bin/karaf server
karaf: java command not found
[vagrant@localhost ~]$ sudo yum install -y java
vagrant@localhost ~]$ sudo /opt/opendaylight/bin/karaf server &
[vagrant@localhost bin]$ ps -u -p `pgrep java` | awk {'print $1'}
root
[~]$ sudo curl -so /etc/yum.repos.d/opendaylight.repo <long Copr URL>
[~]$ sudo yum install -y opendaylight
<snip>
Installed:
opendaylight.noarch 0:0.2.3-2.fc20
Complete!
[~]$ sudo systemctl start opendaylight
[~]$ sudo systemctl is-active opendaylight
active
[/opt/opendaylight/bin]$ ./client
<snip>
opendaylight-user@root>feature:install ...
We work to make contributing easy.
class { 'opendaylight':
install_method => 'tarball',
tarball_url => '<URL to your custom tarball>',
unitfile_url => '<URL to your custom unitfile>',
}
[~]$ less genesis/puppet/opnfv/manifests/network.pp
<snip>
class { "opendaylight":
features => [<OPNFV's Karaf features>],
}
<snip>
[~/puppet-opendaylight]$ bundle exec rake test
---> syntax:manifests
---> syntax:templates
---> syntax:hiera:yaml
Finished in 14.14 seconds (files took 0.53374 seconds to load)
537 examples, 0 failures
Total resources: 17
Touched resources: 17
Resource coverage: 100.00%
metadata-json-lint metadata.json
Bringing machine 'centos-7' up with 'virtualbox' provider...
centos-7 12:45:09$ yum install -y puppet
centos-7 12:45:46$ puppet apply <test manifest>
centos-7 12:49:37$ /bin/sh -c systemctl\ is-active\ opendaylight
active
centos-7 executed in 0.04 seconds
should be running
centos-7 12:49:37$ /bin/sh -c id\ odl
uid=1001(odl) gid=1001(odl) groups=1001(odl)
centos-7 executed in 0.04 seconds
should exist
centos-7 executed in 0.05 seconds
should match /^featuresBoot=standard,ssh/
Finished in 5 minutes 22 seconds (files took 1 minute 10.87 seconds to load)
51 examples, 0 failures
# Box that installs ODL via Puppet RPM method on CentOS 7
config.vm.define "cent7_pup_rpm" do |cent7_pup_rpm|
# Build Vagrant box based on CentOS 7
cent7_pup_rpm.vm.box = "chef/centos-7.0"
# Add EPEL repo for access to Puppet et al
cent7_pup_rpm.vm.provision "shell", inline: "yum install -y epel-release"
# Install Puppet
cent7_pup_rpm.vm.provision "shell", inline: "yum install -y puppet"
# Install OpenDaylight using its Puppet module
cent7_pup_rpm.vm.provision "puppet" do |puppet|
puppet.module_path = ["modules"]
puppet.manifest_file = "odl_install.pp"
end
end
# Install OpenDaylight using its Puppet module
cent7_pup_rpm.vm.provision "puppet" do |puppet|
puppet.module_path = ["modules"]
puppet.manifest_file = "odl_install.pp"
end
puppet.module_path = ["modules"]
[~/vagrant-opendaylight]$ librarian-puppet install
[~/vagrant-opendaylight]$ ls modules
archive java opendaylight stdlib
[~/vagrant-opendaylight]$ cat Puppetfile
#!/usr/bin/env ruby
forge "https://forgeapi.puppetlabs.com"
mod 'dfarrell07-opendaylight',
:git => 'git://github.com/dfarrell07/puppet-opendaylight.git',
:ref => 'origin/master'
puppet.manifest_file = "odl_install.pp"
[~/vagrant-opendaylight]$ cat manifests/odl_install.pp
class { 'opendaylight':
extra_features => ['odl-ovsdb-openstack'],
}
[~/vagrant-opendaylight]$ vagrant up cent7_pup_rpm
Notice: /Stage[main]/Opendaylight::Install/Yumrepo[opendaylight]/ensure: created
Notice: /Stage[main]/Opendaylight::Install/Package[opendaylight]/ensure: created
/Stage[main]/Opendaylight::Config/File[org.apache.karaf.features.cfg]/content: content changed '<hash>' to '<different hash>'
[~/vagrant-opendaylight]$ vagrant ssh cent7_pup_rpm
[vagrant@localhost ~]$
[vagrant@localhost ~]$ sudo systemctl is-active opendaylight
active
[vagrant@localhost ~]$ /vagrant/scripts/connect.sh
opendaylight-user@root>config:list | grep featuresBoot\ =
featuresBoot = <default features>,odl-ovsdb-openstack
opendaylight-user@root>feature:list | grep odl-ovsdb-openstack
odl-ovsdb-openstack | 1.0.3-Helium-SR3 | x | ovsdb-1.0.3-Helium-SR3 <snip>
[~/ansible-opendaylight]$ cat tasks/main.yml
---
- include: add_odl_yum_repo.yml
- include: install_odl_rpm.yml
- include: configure_karaf_features.yml
- include: configure_nb_rest_port.yml
- include: open_nb_rest_port.yml
- include: start_odl_systemd_service.yml
- name: Start ODL systemd service
service:
name=opendaylight
enabled=yes
state=started
- name: Configure ODL Karaf features
template:
src=org.apache.karaf.features.cfg
dest=/opt/opendaylight/etc/
owner=odl
group=odl
notify:
- Stop ODL
- Cleanup Karaf
- Start ODL
[~/ansible-opendaylight]$ wc -l **/*.yml
<snip>
166 total
“don’t unit test your playbook"
“Ansible believes you should not need another framework to validate basic things of your infrastructure”
# Box that installs ODL via its Ansible role on CentOS 7
config.vm.define "cent7_ansible" do |cent7_ansible|
# Build Vagrant box based on CentOS 7
cent7_ansible.vm.box = "chef/centos-7.0"
# Install ODL using the Ansible provisioner
cent7_ansible.vm.provision "ansible" do |ansible|
# Path to playbook that installs ODL using ODL's Ansible role
ansible.playbook = "provisioning/playbook.yml"
end
end
ansible.playbook = "provisioning/playbook.yml"
[~/vagrant-opendaylight]$ cat provisioning/playbook.yml
---
- hosts: all
sudo: yes
roles:
- opendaylight
[~/vagrant-opendaylight]$ vagrant up cent7_ansible
TASK: [opendaylight | Add ODL yum repo] **********************************
changed: [cent7_ansible]
TASK: [opendaylight | Install ODL RPM] ***********************************
changed: [cent7_ansible]
TASK: [opendaylight | Configure ODL Karaf features] **********************
changed: [cent7_ansible]
TASK: [opendaylight | Configure ODL NB REST port] ************************
changed: [cent7_ansible]
TASK: [opendaylight | Check if FirewallD service is running] *************
ok: [cent7_ansible]
TASK: [opendaylight | Open ODL NB REST port via FirewallD] ***************
skipping: [cent7_ansible]
TASK: [opendaylight | Start ODL systemd service] *************************
changed: [cent7_ansible]
[~/vagrant-opendaylight]$ vagrant ssh cent7_ansible
[vagrant@localhost ~]$
[vagrant@localhost ~]$ sudo systemctl is-active opendaylight
active
[~/vagrant-opendaylight]$ cat provisioning/playbook.yml
---
- hosts: all
sudo: yes
roles:
- role: opendaylight
- extra_features: ['odl-ovsdb-openstack']
TASK: [opendaylight | Configure ODL Karaf features] **********************
changed: [cent7_ansible]
NOTIFIED: [opendaylight | Stop ODL] **************************************
changed: [cent7_ansible]
NOTIFIED: [opendaylight | Cleanup Karaf] *********************************
changed: [cent7_ansible]
NOTIFIED: [opendaylight | Start ODL] *************************************
changed: [cent7_ansible]
[~/vagrant-opendaylight]$ vagrant ssh cent7_ansible
[vagrant@localhost ~]$ sudo systemctl is-active opendaylight
active
[vagrant@localhost ~]$ /vagrant/scripts/connect.sh
opendaylight-user@root>config:list | grep odl-ovsdb-openstack
featuresBoot = config,<snip>,odl-ovsdb-openstack
opendaylight-user@root>feature:list | grep odl-ovsdb-openstack
odl-ovsdb-openstack | 1.0.3-Helium-SR3 | x | ovsdb-1.0.3-Helium-SR3 <snip>
[~]$ sudo ansible-galaxy install dfarrell07.opendaylight
[~/sandbox]$ cat /etc/ansible/hosts
odl_box ansible_ssh_host=10.3.12.87 ansible_ssh_user=centos
[~/sandbox]$ cat install_odl.yml
---
- hosts: odl_box
sudo: yes
roles:
- opendaylight
[~/sandbox]$ ansible-playbook install_odl.yml
TASK: [opendaylight | Configure ODL Karaf features] **************************
changed: [odl_box]
TASK: [opendaylight | Start ODL systemd service] *****************************
changed: [odl_box]
[~/sandbox]$ ssh ansible0
[centos@dfarrell-ansible0 ~]$ sudo systemctl is-active opendaylight
active
[centos@dfarrell-ansible0 ~]$ /opt/opendaylight/bin/client
[~/sandbox]$ docker run -ti dfarrell07/odl:0.2.3 ./bin/karaf
[~/sandbox]$ docker ps
CONTACONTAINER ID IMAGE COMMAND
b2869594fab3 dfarrell07/odl:0.2.3 "./bin/karaf"
[~/integration/packaging/docker]$ docker build -t dfarrell07/odl:0.2.3 .
Step 0 : FROM debian:7
---> 479215127fa7
Step 2 : RUN apt-get update && apt-get install -y openjdk-7-jre-headless wget
---> Using cache
---> 7f3f5c682c1c
Step 5 : RUN wget...
Step 6 : EXPOSE 162 179 1088 1790 1830 2400 2550 2551 2552 4189 4342 5005 5666 6633 6640 6653 7800 8000 8080 8101 8181 8383 12001
---> Running in 8625b7f32695
---> 0be36e6be661
Step 9 : CMD ./bin/karaf server
---> Running in 16cab37bf9c2
---> af863ac2de74
[~/sandbox]$ vagrant init -m dfarrell07/opendaylight
[~/sandbox]$ cat Vagrantfile
Vagrant.configure(2) do |config|
config.vm.box = "dfarrell07/opendaylight"
end
[~/sandbox]$ vagrant up
default: URL: https://atlas.hashicorp.com/dfarrell07/opendaylight
==> default: Adding box 'dfarrell07/opendaylight' (v2.3.0)
[~/sandbox]$ vagrant status
Current machine states:
default running (virtualbox)
[~/sandbox]$ vagrant ssh
[vagrant@localhost ~]$ sudo systemctl is-active opendaylight
active
[~/integration/packaging/packer]$ packer build centos.json
"provisioners": [
{
"type": "shell",
"scripts":
[
"config_vagrant.sh",
"config_virtualbox.sh",
"config_ansible.sh"
]
},
#..."provisioners": [
{
"type": "ansible-local",
"playbook_file": "install_odl.yml"
}
"post-processors": [
{
"type": "vagrant",
"compression_level": "9",
"output": "opendaylight-{{ user `box_version` }}-centos-1503.box"
}
]
==> Builds finished. The artifacts of successful builds are:
--> virtualbox' provider box: opendaylight-2.3.0-centos-1503.box
[~/integration/packaging/packer]$ ls -rc | tail -n 1
opendaylight-2.3.0-centos-1503.box
[~/sandbox]$ vagrant box add --name "opendaylight" \
opendaylight-2.3.0-centos-1503.box
[~/sandbox]$ vagrant init -m opendaylight
[~/sandbox]$ cat Vagrantfile
Vagrant.configure(2) do |config|
config.vm.box = "opendaylight"
end
[~/sandbox]$ vagrant up
==> default: Importing base box 'opendaylight'...
[~/sandbox]$ vagrant ssh
[vagrant@localhost ~]$ sudo systemctl is-active opendaylight
active
By Daniel Farrell
Talk given at Open Networking Summit 2015