From 7a908d8a020b693a0e01cde12a79561799b232b0 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 3 Mar 2015 12:29:13 -0700 Subject: [PATCH] Convert DevStack Build Profile to Ansible This change removes Chef from the DevStack build profile and replaces it with an Ansible role. Change-Id: I2976a27aabad7b623bf8d55bc146deff5f14e35e --- ds-build/README.md | 4 +- ds-build/Vagrantfile | 15 ++----- ds-build/cookbooks/ds-build/README.md | 29 -------------- ds-build/cookbooks/ds-build/metadata.rb | 8 ---- .../cookbooks/ds-build/recipes/default.rb | 39 ------------------- ds-build/ds-build.yml | 8 ++++ ds-build/roles/Devstack-Build.json | 18 --------- .../roles/devstack-build/defaults/main.yml | 3 ++ .../devstack-build/files}/autostack.sh | 0 .../devstack-build/files}/local.conf | 0 ds-build/roles/devstack-build/tasks/main.yml | 21 ++++++++++ 11 files changed, 37 insertions(+), 108 deletions(-) delete mode 100644 ds-build/cookbooks/ds-build/README.md delete mode 100644 ds-build/cookbooks/ds-build/metadata.rb delete mode 100644 ds-build/cookbooks/ds-build/recipes/default.rb create mode 100644 ds-build/ds-build.yml delete mode 100644 ds-build/roles/Devstack-Build.json create mode 100644 ds-build/roles/devstack-build/defaults/main.yml rename ds-build/{cookbooks/ds-build/files/default => roles/devstack-build/files}/autostack.sh (100%) rename ds-build/{cookbooks/ds-build/files/default => roles/devstack-build/files}/local.conf (100%) create mode 100644 ds-build/roles/devstack-build/tasks/main.yml diff --git a/ds-build/README.md b/ds-build/README.md index b94b8be..eeff304 100644 --- a/ds-build/README.md +++ b/ds-build/README.md @@ -18,8 +18,8 @@ The following services are enabled: # Upstart instead of screen -The cookbook includes a script which creates Upstart init scripts for each of -the services. It also sets up log files in the `/var/log/` directory. When +The Ansible role includes a script which creates Upstart init scripts for each +of the services. It also sets up log files in the `/var/log/` directory. When the VM is booted, all DevStack processes will start automatically. # Usage diff --git a/ds-build/Vagrantfile b/ds-build/Vagrantfile index ba812f3..8fc3837 100644 --- a/ds-build/Vagrantfile +++ b/ds-build/Vagrantfile @@ -6,15 +6,8 @@ Dir.chdir ".." VAGRANTFILE_API_VERSION = "2" # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -unless Vagrant.has_plugin?("vagrant-berkshelf") - raise "The needed plugin vagrant-berkshelf is not available. - Install it by calling 'vagrant plugin install vagrant-berkshelf'." -end - Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Settings for all vms - config.berkshelf.enabled = true - if Vagrant.has_plugin?("vagrant-cachier") config.cache.scope = :box end @@ -41,11 +34,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| vb.memory = 7180 vb.cpus = 4 end - ds.vm.provision :chef_solo do |chef| - chef.cookbooks_path = "cookbooks" - chef.roles_path = "roles" - chef.add_role "Devstack-Build" - chef.arguments = '--force-formatter' + ds.vm.provision "ansible" do |ansible| + ansible.playbook = "ds-build.yml" + ansible.raw_arguments = ['-T 30', '-e pipelining=True'] end end diff --git a/ds-build/cookbooks/ds-build/README.md b/ds-build/cookbooks/ds-build/README.md deleted file mode 100644 index 8c5b9dc..0000000 --- a/ds-build/cookbooks/ds-build/README.md +++ /dev/null @@ -1,29 +0,0 @@ -ds-build cookbook -========================= -Builds a Devstack VM around Ubuntu Trusty - -This box is used by the Monasca OpenStack monitoring platform. -Based on Ubuntu 14.04 LTS (Trusty Tahr), the box includes -DevStack with the following services enabled: - -- Ceilometer -- Cinder -- Glance -- Heat -- Horizon -- Keystone -- Neutron -- Nova -- Swift - -Additionally, rather than running in screen sessions, all services are started -on boot using Upstart scripts, with logging in appropriate directories under -`/var/log/`. - - -Requirements ------------- - -Recipes ---------- -- default - Installs devstack from source, creates upstart scripts diff --git a/ds-build/cookbooks/ds-build/metadata.rb b/ds-build/cookbooks/ds-build/metadata.rb deleted file mode 100644 index aa87db7..0000000 --- a/ds-build/cookbooks/ds-build/metadata.rb +++ /dev/null @@ -1,8 +0,0 @@ -name "ds-build" -maintainer "Mon Team" -maintainer_email "hpcs-mon@hp.com" -license "All rights reserved" -description "Build customized devstack server" -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "0.0.3" -depends "apt" diff --git a/ds-build/cookbooks/ds-build/recipes/default.rb b/ds-build/cookbooks/ds-build/recipes/default.rb deleted file mode 100644 index 311b44b..0000000 --- a/ds-build/cookbooks/ds-build/recipes/default.rb +++ /dev/null @@ -1,39 +0,0 @@ -# Create a devstack image (https://vagrantcloud.com/monasca/devstack) -# from the latest devstack source - -# Install git -package 'git' do - action :install -end - -# Remove apt proxy (populated by default in ubuntu/trusty64) -file "/etc/apt/apt.conf.d/01proxy" do - action :delete -end - -# Load up devstack configuration and installer script -cookbook_file "local.conf" do - mode 0755 - owner "vagrant" - path "/home/vagrant/local.conf" - action :create_if_missing -end -cookbook_file "autostack.sh" do - mode 0755 - owner "vagrant" - path "/home/vagrant/autostack.sh" - action :create_if_missing -end - -# Install devstack if it hasn't been installed yet -if !::File.exists?("/home/vagrant/devstack/stack-screenrc") - log "Please wait while devstack is installed. This WILL take a while." do - level :info - end - - execute "/home/vagrant/autostack.sh vagrant" -end - -# Make sure a 'localhost' entry exists in /etc/hosts -# It sometimes gets overridden by vagrant -execute "sed -i 's/^127.0.0.1.*/127.0.0.1 devstack localhost/' /etc/hosts" diff --git a/ds-build/ds-build.yml b/ds-build/ds-build.yml new file mode 100644 index 0000000..2e77153 --- /dev/null +++ b/ds-build/ds-build.yml @@ -0,0 +1,8 @@ +- hosts: devstack + sudo: yes + vars: + unpriv_user: vagrant + unpriv_home: /home/{{unpriv_user}} + roles: + - {role: devstack-build, tags: [devstack]} + diff --git a/ds-build/roles/Devstack-Build.json b/ds-build/roles/Devstack-Build.json deleted file mode 100644 index abdc495..0000000 --- a/ds-build/roles/Devstack-Build.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "Devstack-Build", - "description": "Builds up a devstack server with all available services running", - "json_class": "Chef::Role", - "default_attributes": { - "apt": { - "periodic_update_min_delay": 60 - } - }, - "override_attributes": { - }, - "chef_type": "role", - "run_list": [ - "recipe[ds-build]" - ], - "env_run_lists": { - } -} diff --git a/ds-build/roles/devstack-build/defaults/main.yml b/ds-build/roles/devstack-build/defaults/main.yml new file mode 100644 index 0000000..8ba7de0 --- /dev/null +++ b/ds-build/roles/devstack-build/defaults/main.yml @@ -0,0 +1,3 @@ +--- +unpriv_user: vagrant +unpriv_home: /home/{{unpriv_user}} diff --git a/ds-build/cookbooks/ds-build/files/default/autostack.sh b/ds-build/roles/devstack-build/files/autostack.sh similarity index 100% rename from ds-build/cookbooks/ds-build/files/default/autostack.sh rename to ds-build/roles/devstack-build/files/autostack.sh diff --git a/ds-build/cookbooks/ds-build/files/default/local.conf b/ds-build/roles/devstack-build/files/local.conf similarity index 100% rename from ds-build/cookbooks/ds-build/files/default/local.conf rename to ds-build/roles/devstack-build/files/local.conf diff --git a/ds-build/roles/devstack-build/tasks/main.yml b/ds-build/roles/devstack-build/tasks/main.yml new file mode 100644 index 0000000..b791b6b --- /dev/null +++ b/ds-build/roles/devstack-build/tasks/main.yml @@ -0,0 +1,21 @@ +--- +- name: Install git + apt: name=git state=present + +- name: Remove apt proxy (populated by default in ubuntu/trusty64) + file: path=/etc/apt/apt.conf.d/01proxy state=absent + +- name: Install local.conf to the unprivileged user's home directory + copy: src=local.conf dest={{unpriv_home}}/local.conf mode=0755 owner={{unpriv_user}} + +- name: Install autostack.sh script + copy: src=autostack.sh dest={{unpriv_home}}/autostack.sh mode=0755 owner={{unpriv_user}} + +- name: Run DevStack installer (may take 30-90 minutes, depending on bandwidth) + command: "{{unpriv_home}}/autostack.sh {{unpriv_user}}" + args: + chdir: "{{unpriv_home}}" + creates: "{{unpriv_home}}/devstack/stack-screenrc" + +- name: Make sure 'localhost' entry exists in /etc/hosts + lineinfile: dest=/etc/hosts regexp='^127\.0\.0\.1' line='127.0.0.1 devstack localhost' owner=root group=root mode=0644