aboutsummaryrefslogtreecommitdiffstats
path: root/deployment/noheat/infra-openstack/vagrant/Vagrantfile
diff options
context:
space:
mode:
authorPawel Wieczorek <p.wieczorek2@samsung.com>2020-06-15 16:29:35 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-07-30 09:02:56 +0000
commita879e2a54e0641b692202d417021f1824032b123 (patch)
treebfd772a87544023cbe0315eebaa69d1fcaac6256 /deployment/noheat/infra-openstack/vagrant/Vagrantfile
parent3d9bd5abfcb9bf55e3dd1b53cb3b6bc4bd45c0d1 (diff)
Add Ansible roles for OpenStack network
This patch also adds Vagrant provisioners for creating and destroying OpenStack infrastructure. These are set to never run (unless explicitly called by the operator) because DevStack instance on a separate machine might not be ready to provide OpenStack API. This patch is based on previous work by: Krzysztof Opasiak <k.opasiak@samsung.com> Test harness is based on blog post [1] by: Chris Morgan <me@chrismorgan.info> [1] https://chrismorgan.info/blog/make-and-git-diff-test-harness Issue-ID: INT-1601 Change-Id: I031ca7a5a43cca0258dc0dc9e0339182c431898a Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
Diffstat (limited to 'deployment/noheat/infra-openstack/vagrant/Vagrantfile')
-rw-r--r--deployment/noheat/infra-openstack/vagrant/Vagrantfile26
1 files changed, 25 insertions, 1 deletions
diff --git a/deployment/noheat/infra-openstack/vagrant/Vagrantfile b/deployment/noheat/infra-openstack/vagrant/Vagrantfile
index f797675ae..c3b5d9819 100644
--- a/deployment/noheat/infra-openstack/vagrant/Vagrantfile
+++ b/deployment/noheat/infra-openstack/vagrant/Vagrantfile
@@ -1,6 +1,8 @@
# -*- mode: ruby -*-
# -*- coding: utf-8 -*-
+host_folder_ansible = "../ansible"
+synced_folder_ansible = "/ansible"
synced_folder_main = "/vagrant"
synced_folder_config = "#{synced_folder_main}/config"
os_config = "#{synced_folder_config}/local.conf"
@@ -33,6 +35,8 @@ devstack = {
all = [] << operation << devstack
+operation_post_msg = "Run: \"vagrant provision #{operation[:name]} --provision-with=run_playbook_create\" to complete infrastructure deployment"
+
$enable_ipv6 = <<-SCRIPT
sed -i'' 's/net.ipv6.conf.all.disable_ipv6.*$/net.ipv6.conf.all.disable_ipv6 = 0/' /etc/sysctl.conf
sysctl -p
@@ -53,7 +57,7 @@ $setup_py = <<-SCRIPT
curl -fsSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo -H python3 get-pip.py
- pip install python-openstackclient
+ pip install ansible python-openstackclient
mkdir -p #{os_clouds_dir}
SCRIPT
@@ -64,6 +68,13 @@ $link_file = <<-SCRIPT
ln -sf "$src" "$dst"
SCRIPT
+$run_playbook = <<-SCRIPT
+ PLAYBOOK="$1"
+ export OS_CLOUD=openstack
+ cd #{synced_folder_ansible}
+ ansible-playbook "$PLAYBOOK"
+SCRIPT
+
Vagrant.configure("2") do |config|
all.each do |machine|
config.vm.define machine[:name] do |config|
@@ -95,6 +106,7 @@ Vagrant.configure("2") do |config|
if machine[:name] == 'operator'
config.vm.synced_folder ".", synced_folder_main, type: "rsync", rsync__exclude: "Vagrantfile"
+ config.vm.synced_folder host_folder_ansible, synced_folder_ansible, type: "rsync"
config.vm.provision "setup_openstacksdk", type: :shell, privileged: false, inline: $setup_py
config.vm.provision "link_os_clouds", type: :shell, run: "always" do |s|
@@ -102,6 +114,18 @@ Vagrant.configure("2") do |config|
s.inline = $link_file
s.args = [os_clouds, os_clouds_dir]
end
+
+ config.vm.post_up_message = operation_post_msg
+ config.vm.provision "run_playbook_create", type: :shell, run: "never" do |s|
+ s.privileged = false
+ s.inline = $run_playbook
+ s.args = "create.yml"
+ end
+ config.vm.provision "run_playbook_destroy", type: :shell, run: "never" do |s|
+ s.privileged = false
+ s.inline = $run_playbook
+ s.args = "destroy.yml"
+ end
end
end
end