summaryrefslogtreecommitdiffstats
path: root/playbooks
diff options
context:
space:
mode:
authorTlacenka <tlacencin@gmail.com>2017-07-10 15:45:48 +0200
committerTomas Sedovic <tomas@sedovic.cz>2017-07-10 15:45:48 +0200
commit7d92318da75c0f1599465e02d58496e470725796 (patch)
tree65718670457d9e0fa8431d4d3e80c47f9bce625e /playbooks
parent8c0287ed00998dbc0f6f5a7a29377d6348b51e8d (diff)
downloadopenshift-7d92318da75c0f1599465e02d58496e470725796.tar.gz
openshift-7d92318da75c0f1599465e02d58496e470725796.tar.bz2
openshift-7d92318da75c0f1599465e02d58496e470725796.tar.xz
openshift-7d92318da75c0f1599465e02d58496e470725796.zip
Playbook prerequisites.yml checks that prerequisites are met before provisioning (#518)
* prerequisites.yml: check prerequisites on localhost needed for provisioning provision.yml: includes prerequisites.yml * prerequisites: indentation fixed * prerequisites.yml: used ansible_version variable, openstack modules for ansible * prerequisites.yml: os_keypair is not suitable for this purpose * prerequisites.yml: openstack keypair command exchanged for shade - there is no Ansible module for this now - os_keypair is not suitable for this purpose - python-openstackclient dependency is not desirable
Diffstat (limited to 'playbooks')
-rw-r--r--playbooks/provisioning/openstack/prerequisites.yml76
-rw-r--r--playbooks/provisioning/openstack/provision.yaml2
2 files changed, 78 insertions, 0 deletions
diff --git a/playbooks/provisioning/openstack/prerequisites.yml b/playbooks/provisioning/openstack/prerequisites.yml
new file mode 100644
index 000000000..71a99fc82
--- /dev/null
+++ b/playbooks/provisioning/openstack/prerequisites.yml
@@ -0,0 +1,76 @@
+---
+- hosts: localhost
+ tasks:
+
+ # Check ansible
+ - name: Check Ansible version
+ assert:
+ that: >
+ (ansible_version.major == 2 and ansible_version.minor >= 3) or
+ (ansible_version.major > 2)
+ msg: "Ansible version must be at least 2.3"
+
+ # Check shade
+ - name: Try to import python module shade
+ command: python -c "import shade"
+ ignore_errors: yes
+ register: shade_result
+ - name: Check if shade is installed
+ assert:
+ that: 'shade_result.rc == 0'
+ msg: "Python module shade is not installed"
+
+ # Check python-dns
+ - name: Try to import python DNS module
+ command: python -c "import dns"
+ ignore_errors: yes
+ register: pythondns_result
+ - name: Check if python-dns is installed
+ assert:
+ that: 'pythondns_result.rc == 0'
+ msg: "Python module python-dns is not installed"
+
+ # Check jinja2
+ - name: Try to import jinja2 module
+ command: python -c "import jinja2"
+ ignore_errors: yes
+ register: jinja_result
+ - name: Check if jinja2 is installed
+ assert:
+ that: 'jinja_result.rc == 0'
+ msg: "Python module jinja2 is not installed"
+
+ # Check Glance image
+ - name: Try to get image facts
+ os_image_facts:
+ image: "{{ openstack_default_image_name }}"
+ register: image_result
+ - name: Check that image is available
+ assert:
+ that: "image_result.ansible_facts.openstack_image"
+ msg: "Image {{ openstack_default_image_name }} is not available"
+
+ # Check network name
+ - name: Try to get network facts
+ os_networks_facts:
+ name: "{{ openstack_external_network_name }}"
+ register: network_result
+ - name: Check that network is available
+ assert:
+ that: "network_result.ansible_facts.openstack_networks"
+ msg: "Network {{ openstack_external_network_name }} is not available"
+
+ # Check keypair
+ # TODO kpilatov: there is no Ansible module for getting OS keypairs
+ # (os_keypair is not suitable for this)
+ # this method does not force python-openstackclient dependency
+ - name: Try to show keypair
+ command: >
+ python -c 'import shade; cloud = shade.openstack_cloud();
+ exit(cloud.get_keypair("{{ openstack_ssh_public_key }}") is None)'
+ ignore_errors: yes
+ register: key_result
+ - name: Check that keypair is available
+ assert:
+ that: 'key_result.rc == 0'
+ msg: "Keypair {{ openstack_ssh_public_key }} is not available"
diff --git a/playbooks/provisioning/openstack/provision.yaml b/playbooks/provisioning/openstack/provision.yaml
index 7cde5e8b8..92b6d3356 100644
--- a/playbooks/provisioning/openstack/provision.yaml
+++ b/playbooks/provisioning/openstack/provision.yaml
@@ -1,4 +1,6 @@
---
+- include: "prerequisites.yml"
+
- include: "provision-openstack.yml"
- include: "pre-install.yml"