Merge "Handle ansible quote trolling."

This commit is contained in:
Alex Krzos
2016-03-10 02:10:46 +01:00
committed by Gerrit Code Review
3 changed files with 64 additions and 57 deletions

View File

@@ -1,7 +1,13 @@
def dict_remove(the_dict, item):
"""Remove an item from a dictionary."""
del the_dict[item]
return the_dict
def hosts_to_dictionary(arg): def hosts_to_dictionary(arg):
"""Changes list format of hosts to dictionary format. The key of the dictionary is the index """Changes list format of hosts to dictionary format. The key of the dictionary is the index
of the host. The index is defined by the host's suffix, example: overcloud-controller-10 is 10. of the host. The index is defined by the host's suffix, example: overcloud-controller-10 is 10.
If there is no suffix, I use an increamented value above 1000000.""" If there is no suffix, I use an incremented value above 1000000."""
dictionary = {} dictionary = {}
nonindex = 1000000 nonindex = 1000000
@@ -17,4 +23,7 @@ def hosts_to_dictionary(arg):
class FilterModule(object): class FilterModule(object):
def filters(self): def filters(self):
return {'hosts_to_dictionary': hosts_to_dictionary} return {
'dict_remove': dict_remove,
'hosts_to_dictionary': hosts_to_dictionary,
}

View File

@@ -11,7 +11,7 @@ local_remote_user: stack
# The Overcloud RC file # The Overcloud RC file
overcloudrc: /home/stack/overcloudrc overcloudrc: /home/stack/overcloudrc
# The default Browbeat # The default Browbeat venv
browbeat_venv: /home/stack/browbeat-venv browbeat_venv: /home/stack/browbeat-venv
# The default Rally venv # The default Rally venv
@@ -26,9 +26,12 @@ perfkit_venv: /home/stack/perfkit-venv
# Shaker centos image builder template # Shaker centos image builder template
shaker_centos: "{{shaker_venv}}/lib/python2.7/site-packages/shaker/resources/image_builder_templates/centos.yaml" shaker_centos: "{{shaker_venv}}/lib/python2.7/site-packages/shaker/resources/image_builder_templates/centos.yaml"
# Guest images for the Over cloud # Guest images for the Overcloud
centos_image_url: http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 images:
cirros_image_url: http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img centos7:
url: http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2
cirros:
url: http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
# Host where connmond will be running # Host where connmond will be running
connmon_host: 192.0.2.1 connmon_host: 192.0.2.1

View File

@@ -23,54 +23,59 @@
become: true become: true
- name: Create browbeat virtualenv - name: Create browbeat virtualenv
command: virtualenv "{{ browbeat_venv }}" creates=""{{ browbeat_venv }}"" command: virtualenv {{ browbeat_venv }} creates={{ browbeat_venv }}
- name: Create perfkit virtualenv - name: Create perfkit virtualenv
command: virtualenv "{{ perfkit_venv }}" creates=""{{ perfkit_venv }}"" command: virtualenv {{ perfkit_venv }} creates={{ perfkit_venv }}
- name: Create rally virtualenv - name: Create rally virtualenv
command: virtualenv "{{ rally_venv }}" creates=""{{ rally_venv }}"" command: virtualenv {{ rally_venv }} creates={{ rally_venv }}
- name: Create shaker virtualenv - name: Create shaker virtualenv
command: virtualenv "{{ shaker_venv }}" creates=""{{ shaker_venv }}"" command: virtualenv {{ shaker_venv }} creates={{ shaker_venv }}
- name: Determine if browbeat directory exists already
stat: path={{ home_dir }}/browbeat
register: browbeat_exists
- debug: msg="Browbeat directory exists already."
when: browbeat_exists.stat.isdir is defined and browbeat_exists.stat.isdir
- name: Clone browbeat on undercloud - name: Clone browbeat on undercloud
git: repo=https://github.com/jtaleric/browbeat.git dest="{{ home_dir }}"/browbeat git: repo=https://github.com/jtaleric/browbeat.git dest={{ home_dir }}/browbeat
when: "'localhost' not in '{{ inventory_hostname }}'" when: browbeat_exists.stat.isdir is undefined
- name: Generate hosts and ~/.ssh/config on undercloud - name: Generate hosts and ~/.ssh/config on undercloud
shell: . "{{ home_dir }}"/stackrc; "{{ home_dir }}"/browbeat/ansible/gen_hostfile.sh localhost "{{ home_dir }}"/.ssh/config shell: . {{ home_dir }}/stackrc; {{ home_dir }}/browbeat/ansible/gen_hostfile.sh localhost {{ home_dir }}/.ssh/config
when: "'localhost' not in '{{ inventory_hostname }}'"
- name: Move hosts file to correct location - name: Move hosts file to correct location
command: mv "{{ home_dir }}"/hosts "{{ home_dir }}"/browbeat/ansible/hosts command: mv {{ home_dir }}/hosts {{ home_dir }}/browbeat/ansible/hosts
when: "'localhost' not in '{{ inventory_hostname }}'"
- name: Install requirements.txt into browbeat-venv - name: Install requirements.txt into browbeat-venv
pip: requirements="{{ browbeat_path }}"/requirements.txt virtualenv=""{{ browbeat_venv }}"" pip: requirements={{ browbeat_path }}/requirements.txt virtualenv={{ browbeat_venv }}
become: true become: true
- name: Clone PerfKitBenchmarker on undercloud - name: Clone PerfKitBenchmarker on undercloud
git: repo=https://github.com/GoogleCloudPlatform/PerfKitBenchmarker.git dest="{{ perfkit_venv }}"/PerfKitBenchmarker git: repo=https://github.com/GoogleCloudPlatform/PerfKitBenchmarker.git dest={{ perfkit_venv }}/PerfKitBenchmarker
- name: Install PerfKitBenchmarker requirements into perfkit-venv - name: Install PerfKitBenchmarker requirements into perfkit-venv
pip: requirements="{{ perfkit_venv }}"/PerfKitBenchmarker/requirements.txt virtualenv="{{ perfkit_venv }}" pip: requirements={{ perfkit_venv }}/PerfKitBenchmarker/requirements.txt virtualenv={{ perfkit_venv }}
- name: Install PerfKitBenchmarker Openstack requirements into perfkit-venv - name: Install PerfKitBenchmarker Openstack requirements into perfkit-venv
pip: requirements="{{ perfkit_venv }}"/PerfKitBenchmarker/requirements-openstack.txt virtualenv="{{ perfkit_venv }}" pip: requirements={{ perfkit_venv }}/PerfKitBenchmarker/requirements-openstack.txt virtualenv={{ perfkit_venv }}
- name: Install rally into rally-venv - name: Install rally into rally-venv
pip: name=rally virtualenv="{{ rally_venv }}" pip: name=rally virtualenv={{ rally_venv }}
become: true become: true
- name: Setup rally database - name: Setup rally database
shell: . "{{ rally_venv}}"/bin/activate; rally-manage db recreate shell: . {{ rally_venv }}/bin/activate; rally-manage db recreate
- name: Setup rally deployment - name: Setup rally deployment
shell: . "{{ rally_venv }}"/bin/activate; . "{{ overcloudrc }}"; rally deployment create --fromenv --name overcloud shell: . {{ rally_venv }}/bin/activate; . {{ overcloudrc }}; rally deployment create --fromenv --name overcloud
- name: Install shaker - name: Install shaker
pip: name=pyshaker version=0.0.10 virtualenv=""{{ shaker_venv }}"" pip: name=pyshaker version=0.0.10 virtualenv={{ shaker_venv }}
- name: Check for shaker port in iptables - name: Check for shaker port in iptables
shell: iptables -nvL | grep -q "dpt:"{{ shaker_port }}"" shell: iptables -nvL | grep -q "dpt:"{{ shaker_port }}""
@@ -123,46 +128,36 @@
when: results_in_httpd when: results_in_httpd
# #
# Nova boot image tasks # Obtain and upload images for use with browbeat
# #
- name: Fetch cirros image - name: Fetch image
get_url: url={{ cirros_image_url }} dest="{{ home_dir }}"/cirros.img get_url: url={{ images[item].url }} dest={{ home_dir }}/{{ item }}
with_items: "{{ images }}"
- name: Determine is cirros image exists - name: Determine if image exists
shell: . "{{ overcloudrc }}"; glance image-list | grep "cirros" shell: . {{ overcloudrc }}; glance image-list | grep '{{ item }}'
register: cirros_image_exists register: image_exists
ignore_errors: true ignore_errors: true
changed_when: false changed_when: false
with_items: "{{ images }}"
- name: Upload cirros image into cloud (OSP8) - name: Remove image from dictionary of images if image exists
shell: . "{{ overcloudrc }}"; glance image-create --name cirros --visibility public --disk-format=qcow2 --container-format=bare < "{{ home_dir }}"/cirros.img set_fact: images="{{ images|dict_remove(item[0]) }}"
when: "'cirros' not in '{{ cirros_image_exists.stdout }}'" when: "'{{ item[0] }}' in '{{ item[1].stdout }}'"
register: cirros_image_osp8 with_nested:
- "{{ images }}"
- "{{ image_exists.results }}"
- name: Upload image into cloud (OSP8)
shell: . {{ overcloudrc }}; glance image-create --name {{ item }} --visibility public --disk-format=qcow2 --container-format=bare < {{ home_dir }}/{{ item }}
register: image_osp8
ignore_errors: true ignore_errors: true
with_items: "{{ images }}"
- name: Upload cirros image into cloud (OSP7) - name: Upload image into cloud (OSP7)
shell: . "{{ overcloudrc }}"; glance image-create --name cirros --is-public true --disk-format=qcow2 --container-format=bare < "{{ home_dir }}"/cirros.img shell: . {{ overcloudrc }}; glance image-create --name {{ item.item }} --is-public true --disk-format=qcow2 --container-format=bare < {{ home_dir }}/{{ item.item }}
when: "'cirros' not in '{{ cirros_image_exists.stdout }}' and not cirros_image_osp8.rc == 0" when: not item.rc == 0
ignore_errors: true ignore_errors: true
with_items: "{{ image_osp8.results }}"
- name: Fetch centos7 image
get_url: url={{ centos_image_url }} dest="{{ home_dir }}"/centos7.qcow2
- name: Determine is centos7 image exists
shell: . "{{ overcloudrc }}"; glance image-list | grep "centos7"
register: centos7_image_exists
ignore_errors: true
changed_when: false
- name: Upload centos7 image into cloud (OSP8)
shell: . "{{ overcloudrc }}"; glance image-create --name centos7 --visibility public --disk-format=qcow2 --container-format=bare < "{{ home_dir }}"/centos7.qcow2
when: "'centos7' not in '{{ centos7_image_exists.stdout }}'"
register: centos7_image_osp8
ignore_errors: true
- name: Upload centos7 image into cloud (OSP7)
shell: . "{{ overcloudrc }}"; glance image-create --name centos7 --is-public true --disk-format=qcow2 --container-format=bare < "{{ home_dir }}"/centos7.qcow2
when: "'centos7' not in '{{ centos7_image_exists.stdout }}' and not centos7_image_osp8.rc == 0"
ignore_errors: true