Fix variable has no attribute ldap error during package build
Also test domains
Change-Id: I019f0cfa07dd3185c16a958ed0aefc92fed57460
diff --git a/.kitchen.yml b/.kitchen.yml
index 32e9f68..7ef9ad1 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -74,6 +74,13 @@
pillars-from-files:
keystone.sls: tests/pillar/single.sls
+ - name: single_domain
+ provisioner:
+ grains:
+ noservices: True
+ pillars-from-files:
+ keystone.sls: tests/pillar/single_domain.sls
+
- name: single_fernet
provisioner:
pillars-from-files:
diff --git a/.travis.yml b/.travis.yml
index a9b99a0..7cf63e4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,6 +19,8 @@
env:
- PLATFORM=trevorj/salty-whales:trusty MYSQL_VERSION='5.5' SUITE=single
- PLATFORM=trevorj/salty-whales:xenial MYSQL_VERSION='5.7' SUITE=single
+ - PLATFORM=trevorj/salty-whales:trusty MYSQL_VERSION='5.5' SUITE=single_domain
+ - PLATFORM=trevorj/salty-whales:xenial MYSQL_VERSION='5.7' SUITE=single_domain
- PLATFORM=trevorj/salty-whales:trusty MYSQL_VERSION='5.5' SUITE=single_fernet
- PLATFORM=trevorj/salty-whales:xenial MYSQL_VERSION='5.7' SUITE=single_fernet
- PLATFORM=trevorj/salty-whales:trusty MYSQL_VERSION='5.5' SUITE=under-apache
diff --git a/keystone/server.sls b/keystone/server.sls
index b29e39e..e330933 100644
--- a/keystone/server.sls
+++ b/keystone/server.sls
@@ -5,7 +5,18 @@
pkg.installed:
- names: {{ server.pkgs }}
-{%- if server.get('backend') == 'ldap' or server.get('domain',{}).itervalues() | selectattr('ldap') | list %}
+{%- set ldap = {'enabled': False} %}
+{%- if server.get('backend') == 'ldap' %}
+ {%- do ldap.update({'enabled': True}) %}
+{%- else %}
+ {%- for domain in server.get('domain', {}).itervalues() %}
+ {%- if domain.get('ldap') %}
+ {%- do ldap.update({'enabled': True}) %}
+ {%- endif %}
+ {%- endfor %}
+{%- endif %}
+
+{%- if ldap.enabled %}
keystone_ldap_packages:
pkg.installed:
- names:
@@ -184,7 +195,7 @@
keystone_domain_{{ domain_name }}:
cmd.run:
- name: source /root/keystonercv3 && openstack domain create --description "{{ domain.description }}" {{ domain_name }}
- - unless: source /root/keystonercv3 && openstack domain list | grep " {{ domain_name }}"
+ - unless: {% if grains.get('noservices') %}/bin/true{% else %}source /root/keystonercv3 && openstack domain list | grep " {{ domain_name }}"{% endif %}
- shell: /bin/bash
- require:
- file: /root/keystonercv3
diff --git a/tests/pillar/single_domain.sls b/tests/pillar/single_domain.sls
new file mode 100644
index 0000000..be0272e
--- /dev/null
+++ b/tests/pillar/single_domain.sls
@@ -0,0 +1,72 @@
+keystone:
+# Server state
+ server:
+ enabled: true
+ version: liberty
+ service_token: RANDOMSTRINGTOKEN
+ service_tenant: service
+ admin_tenant: admin
+ admin_name: admin
+ admin_password: passw0rd
+ admin_email: root@localhost
+ bind:
+ address: 0.0.0.0
+ private_address: 127.0.0.1
+ private_port: 35357
+ public_address: 127.0.0.1
+ public_port: 5000
+ region: RegionOne
+ database:
+ engine: mysql
+ host: localhost
+ name: keystone
+ password: passw0rd
+ user: keystone
+ tokens:
+ engine: cache
+ expiration: 86400
+ location: /etc/keystone/fernet-keys/
+ notification: false
+ notification_format: cadf
+ domain:
+ testing:
+ description: "Testing domain"
+ backend: ldap
+ assignment:
+ backend: sql
+ ldap:
+ url: "ldaps://idm.domain.com"
+ suffix: "dc=cloud,dc=domain,dc=com"
+ uid: keystone
+ password: password
+# CI related dependencies
+mysql:
+ client:
+ enabled: true
+ version: '5.7'
+ admin:
+ host: localhost
+ port: 3306
+ user: admin
+ password: password
+ encoding: utf8
+ server:
+ enabled: true
+ version: "5.7"
+ force_encoding: utf8
+ bind:
+ address: 0.0.0.0
+ port: 3306
+ protocol: tcp
+ database:
+ keystone:
+ encoding: utf8
+ users:
+ - host: '%'
+ name: keystone
+ password: passw0rd
+ rights: all
+ - host: 127.0.0.1
+ name: keystone
+ password: passw0rd
+ rights: all