Rename custom "ini" module to "validations_read_ini"
It makes name collision less possible, and should avoid some issues with the existing "ini" lookup Change-Id: I3af2cf16fdea5a46748ff828c9d9b5844019de1c
This commit is contained in:
parent
6df86cdffe
commit
d749c1a1c6
|
@ -1,15 +0,0 @@
|
|||
============
|
||||
Module - ini
|
||||
============
|
||||
|
||||
|
||||
This module provides for the following ansible plugin:
|
||||
|
||||
* ini
|
||||
|
||||
|
||||
.. ansibleautoplugin::
|
||||
:module: library/ini.py
|
||||
:documentation: true
|
||||
:examples: true
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
=============================
|
||||
Module - validations_read_ini
|
||||
=============================
|
||||
|
||||
|
||||
This module provides for the following ansible plugin:
|
||||
|
||||
* validations_read_ini
|
||||
|
||||
|
||||
.. ansibleautoplugin::
|
||||
:module: library/validations_read_ini.py
|
||||
:documentation: true
|
||||
:examples: true
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
# Ansible module to read a value from an Ini file.
|
||||
# Usage:
|
||||
# - ini: path=/path/to/file.ini section=default key=something
|
||||
# - validations_read_ini: path=/path/to/file.ini section=default key=something
|
||||
# register: my_ini
|
||||
#
|
||||
# This will read the `path/to/file.ini` file and read the `Hello!` value under:
|
||||
|
@ -89,7 +89,7 @@ def get_result(path, section, key, default=None):
|
|||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ini
|
||||
module: validations_read_ini
|
||||
short_description: Get data from an ini file
|
||||
description:
|
||||
- Get data from an ini file
|
||||
|
@ -125,7 +125,7 @@ EXAMPLES = '''
|
|||
- hosts: webservers
|
||||
tasks:
|
||||
- name: Lookup bar value
|
||||
ini: path=config.ini section=foo key=bar ignore_missing_file=True
|
||||
validations_read_ini: path=config.ini section=foo key=bar ignore_missing_file=True
|
||||
'''
|
||||
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
name: "tripleo_undercloud_conf_file"
|
||||
|
||||
- name: Check if telemetry services are enabled
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: enable_telemetry
|
||||
|
@ -24,7 +24,7 @@
|
|||
|
||||
- name: Get event ttl from panko configuration file
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ panko_config_file }}"
|
||||
section: database
|
||||
key: "{{ event_ttl_check }}"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
- name: Get the local_subnet name from the undercloud_conf file
|
||||
become: True
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: local_subnet
|
||||
|
@ -15,7 +15,7 @@
|
|||
|
||||
- name: Get gateway value from the undercloud.conf file
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: "{% if local_subnet.value %}{{ local_subnet.value }}{% else %}ctlplane-subnet{% endif %}"
|
||||
key: gateway
|
||||
|
@ -24,7 +24,7 @@
|
|||
|
||||
- name: Get local_ip value from the undercloud.conf file
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: local_ip
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
name: "tripleo_undercloud_conf_file"
|
||||
|
||||
- name: Get container client from undercloud.conf
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: container_cli
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- name: Fetch token value
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ keystone_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: admin_token
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
- name: Get dhcp_start value from the undercloud.conf file
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: ctlplane-subnet
|
||||
key: dhcp_start
|
||||
|
@ -16,7 +16,7 @@
|
|||
|
||||
- name: Get dhcp_end value from the undercloud.conf file
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: ctlplane-subnet
|
||||
key: dhcp_end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- name: Look up the introspection interface
|
||||
become: True
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ ironic_inspector_conf }}"
|
||||
section: iptables
|
||||
key: dnsmasq_interface
|
||||
|
@ -9,7 +9,7 @@
|
|||
|
||||
- name: Look up the introspection interface from the deprecated option
|
||||
become: True
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ ironic_inspector_conf }}"
|
||||
section: firewall
|
||||
key: dnsmasq_interface
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
hiera: name="tripleo_undercloud_conf_file"
|
||||
|
||||
- name: Gather undercloud.conf values
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: local_interface
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
- name: Get local_ip value from the undercloud.conf file
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: local_ip
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
- name: Get the Container CLI from the undercloud.conf file
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: container_cli
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- name: Read the `firewall_driver` value
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ nova_conf_path }}"
|
||||
section: DEFAULT
|
||||
key: firewall_driver
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- name: Get Ironic Inspector swift auth_url
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ ironic_conf_file }}"
|
||||
section: inspector
|
||||
key: auth_url
|
||||
|
@ -9,7 +9,7 @@
|
|||
|
||||
- name: Get Ironic Inspector swift password
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ ironic_conf_file }}"
|
||||
section: inspector
|
||||
key: password
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- name: Get VIF Plugging setting values from nova.conf
|
||||
become: True
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ nova_config_file }}"
|
||||
section: DEFAULT
|
||||
key: "{{ item }}"
|
||||
|
@ -29,7 +29,7 @@
|
|||
|
||||
- name: Get auth_url value from neutron.conf
|
||||
become: True
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ neutron_config_file }}"
|
||||
section: nova
|
||||
key: auth_url
|
||||
|
@ -46,7 +46,7 @@
|
|||
|
||||
- name: Get Notify Nova settings values from neutron.conf
|
||||
become: True
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ neutron_config_file }}"
|
||||
section: DEFAULT
|
||||
key: "{{ item }}"
|
||||
|
@ -64,7 +64,7 @@
|
|||
|
||||
- name: Get Tenant Name setting value from neutron.conf
|
||||
become: True
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ neutron_config_file }}"
|
||||
section: nova
|
||||
key: "{{ tenant_name_check }}"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- name: Get Ironic Inspector swift auth_url
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ ironic_inspector_conf_file }}"
|
||||
section: swift
|
||||
key: auth_url
|
||||
|
@ -9,7 +9,7 @@
|
|||
|
||||
- name: Get Ironic Inspector swift password
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ ironic_inspector_conf_file }}"
|
||||
section: swift
|
||||
key: password
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
# running the playbook. We assume that all of the hosts are in the same realm, so
|
||||
# this is not a problem for now.
|
||||
- name: Set fact for IdM/FreeIPA realm
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "/etc/ipa/default.conf"
|
||||
section: global
|
||||
key: realm
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
- name: Get novajoin keytab path from join.conf
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ joinconf_location }}"
|
||||
section: DEFAULT
|
||||
key: keytab
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
- name: Get novajoin server port from join.conf
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ joinconf_location }}"
|
||||
section: DEFAULT
|
||||
key: join_listen_port
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
- name: Get novajoin server host from join.conf
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ joinconf_location }}"
|
||||
section: DEFAULT
|
||||
key: join_listen
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
- name: Get novajoin keytab path from join.conf
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ joinconf_location }}"
|
||||
section: DEFAULT
|
||||
key: keytab
|
||||
|
@ -26,7 +26,7 @@
|
|||
|
||||
- name: Get novajoin server port from join.conf
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ joinconf_location }}"
|
||||
section: DEFAULT
|
||||
key: join_listen_port
|
||||
|
@ -36,7 +36,7 @@
|
|||
|
||||
- name: Get novajoin server host from join.conf
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ joinconf_location }}"
|
||||
section: DEFAULT
|
||||
key: join_listen
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
- name: Get the Container CLI from the undercloud.conf file (stein+)
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: container_cli
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
- name: Verify that nameservers are set in undercloud.conf
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: undercloud_nameservers
|
||||
|
@ -56,7 +56,7 @@
|
|||
|
||||
- name: Get domain as set in undercloud.conf
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: overcloud_domain_name
|
||||
|
@ -92,7 +92,7 @@
|
|||
|
||||
- name: Get enable_novajoin flag from undercloud.conf
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: enable_novajoin
|
||||
|
|
|
@ -18,7 +18,7 @@ Role Variables
|
|||
Dependencies
|
||||
------------
|
||||
|
||||
- 'ini' custom plugin
|
||||
- 'validations_read_ini' custom plugin
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- name: Check the services for debug flag
|
||||
become: True
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ item }}"
|
||||
section: DEFAULT
|
||||
key: debug
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
- name: Get the Container CLI from the undercloud.conf file
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: container_cli
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
- name: Get the Container CLI from the undercloud.conf file
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: container_cli
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
- name: Get the Container CLI from the undercloud.conf file
|
||||
become: true
|
||||
ini:
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: container_cli
|
||||
|
|
|
@ -13,17 +13,17 @@
|
|||
# under the License.
|
||||
|
||||
"""
|
||||
test_ini
|
||||
test_validations_read_ini
|
||||
----------------------------------
|
||||
|
||||
Tests for `ini` module.
|
||||
Tests for `validations_read_ini` module.
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import library.ini as validation
|
||||
import library.validations_read_ini as validation
|
||||
from tripleo_validations.tests import base
|
||||
|
||||
|
||||
|
@ -45,24 +45,24 @@ password=1234
|
|||
'''
|
||||
|
||||
|
||||
class TestIni(base.TestCase):
|
||||
class TestValidationsReadIni(base.TestCase):
|
||||
|
||||
def test_check_file_invalid_path(self):
|
||||
'''Test ini when path is invalid'''
|
||||
'''Test validations_read_ini when path is invalid'''
|
||||
|
||||
msg = validation.check_file('non/existing/path', False)
|
||||
self.assertEqual("Could not open the ini file: 'non/existing/path'",
|
||||
msg)
|
||||
|
||||
def test_check_file_ignore_missing(self):
|
||||
'''Test ini when ignoring missing files'''
|
||||
'''Test validations_read_ini when ignoring missing files'''
|
||||
|
||||
msg = validation.check_file('non/existing/path', True)
|
||||
self.assertEqual("Could not open the ini file: 'non/existing/path'",
|
||||
msg)
|
||||
|
||||
def test_check_file_valid_path(self):
|
||||
'''Test ini when path is valid'''
|
||||
'''Test validations_read_ini when path is valid'''
|
||||
|
||||
tmpfile = self.create_tmp_ini()
|
||||
tmp_name = os.path.relpath(tmpfile.name)
|
||||
|
@ -72,7 +72,7 @@ class TestIni(base.TestCase):
|
|||
self.assertEqual('', msg)
|
||||
|
||||
def test_get_result_invalid_format(self):
|
||||
'''Test ini when file format is valid'''
|
||||
'''Test validations_read_ini when file format is valid'''
|
||||
|
||||
tmpfile = self.create_tmp_ini()
|
||||
tmp_name = os.path.relpath(tmpfile.name)
|
||||
|
@ -87,7 +87,7 @@ class TestIni(base.TestCase):
|
|||
self.assertIsNone(value)
|
||||
|
||||
def test_get_result_key_not_found(self):
|
||||
'''Test ini when key is not found'''
|
||||
'''Test validations_read_ini when key is not found'''
|
||||
|
||||
tmpfile = self.create_tmp_ini()
|
||||
tmp_name = os.path.relpath(tmpfile.name)
|
||||
|
@ -102,7 +102,7 @@ class TestIni(base.TestCase):
|
|||
self.assertIsNone(value)
|
||||
|
||||
def test_get_result_key_not_found_with_default(self):
|
||||
'''Test ini when key is not found but has a default'''
|
||||
'''Test validations_read_ini when key is not found but has a default'''
|
||||
|
||||
tmpfile = self.create_tmp_ini()
|
||||
tmp_name = os.path.relpath(tmpfile.name)
|
||||
|
@ -119,7 +119,7 @@ class TestIni(base.TestCase):
|
|||
self.assertEqual(value, 'foo')
|
||||
|
||||
def test_get_result_ok(self):
|
||||
'''Test ini when key is not found'''
|
||||
'''Test validations_read_ini when key is not found'''
|
||||
|
||||
tmpfile = self.create_tmp_ini()
|
||||
tmp_name = os.path.relpath(tmpfile.name)
|
Loading…
Reference in New Issue