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:
Cédric Jeanneret 2019-11-22 15:50:43 +01:00
parent 6df86cdffe
commit d749c1a1c6
27 changed files with 68 additions and 68 deletions

View File

@ -1,15 +0,0 @@
============
Module - ini
============
This module provides for the following ansible plugin:
* ini
.. ansibleautoplugin::
:module: library/ini.py
:documentation: true
:examples: true

View File

@ -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

View File

@ -16,7 +16,7 @@
# Ansible module to read a value from an Ini file. # Ansible module to read a value from an Ini file.
# Usage: # 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 # register: my_ini
# #
# This will read the `path/to/file.ini` file and read the `Hello!` value under: # 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 = ''' DOCUMENTATION = '''
--- ---
module: ini module: validations_read_ini
short_description: Get data from an ini file short_description: Get data from an ini file
description: description:
- Get data from an ini file - Get data from an ini file
@ -125,7 +125,7 @@ EXAMPLES = '''
- hosts: webservers - hosts: webservers
tasks: tasks:
- name: Lookup bar value - 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
''' '''

View File

@ -11,7 +11,7 @@
name: "tripleo_undercloud_conf_file" name: "tripleo_undercloud_conf_file"
- name: Check if telemetry services are enabled - name: Check if telemetry services are enabled
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: enable_telemetry key: enable_telemetry
@ -24,7 +24,7 @@
- name: Get event ttl from panko configuration file - name: Get event ttl from panko configuration file
become: true become: true
ini: validations_read_ini:
path: "{{ panko_config_file }}" path: "{{ panko_config_file }}"
section: database section: database
key: "{{ event_ttl_check }}" key: "{{ event_ttl_check }}"

View File

@ -6,7 +6,7 @@
- name: Get the local_subnet name from the undercloud_conf file - name: Get the local_subnet name from the undercloud_conf file
become: True become: True
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: local_subnet key: local_subnet
@ -15,7 +15,7 @@
- name: Get gateway value from the undercloud.conf file - name: Get gateway value from the undercloud.conf file
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: "{% if local_subnet.value %}{{ local_subnet.value }}{% else %}ctlplane-subnet{% endif %}" section: "{% if local_subnet.value %}{{ local_subnet.value }}{% else %}ctlplane-subnet{% endif %}"
key: gateway key: gateway
@ -24,7 +24,7 @@
- name: Get local_ip value from the undercloud.conf file - name: Get local_ip value from the undercloud.conf file
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: local_ip key: local_ip

View File

@ -16,7 +16,7 @@
name: "tripleo_undercloud_conf_file" name: "tripleo_undercloud_conf_file"
- name: Get container client from undercloud.conf - name: Get container client from undercloud.conf
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: container_cli key: container_cli

View File

@ -1,7 +1,7 @@
--- ---
- name: Fetch token value - name: Fetch token value
become: true become: true
ini: validations_read_ini:
path: "{{ keystone_conf_file }}" path: "{{ keystone_conf_file }}"
section: DEFAULT section: DEFAULT
key: admin_token key: admin_token

View File

@ -6,7 +6,7 @@
- name: Get dhcp_start value from the undercloud.conf file - name: Get dhcp_start value from the undercloud.conf file
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: ctlplane-subnet section: ctlplane-subnet
key: dhcp_start key: dhcp_start
@ -16,7 +16,7 @@
- name: Get dhcp_end value from the undercloud.conf file - name: Get dhcp_end value from the undercloud.conf file
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: ctlplane-subnet section: ctlplane-subnet
key: dhcp_end key: dhcp_end

View File

@ -1,7 +1,7 @@
--- ---
- name: Look up the introspection interface - name: Look up the introspection interface
become: True become: True
ini: validations_read_ini:
path: "{{ ironic_inspector_conf }}" path: "{{ ironic_inspector_conf }}"
section: iptables section: iptables
key: dnsmasq_interface key: dnsmasq_interface
@ -9,7 +9,7 @@
- name: Look up the introspection interface from the deprecated option - name: Look up the introspection interface from the deprecated option
become: True become: True
ini: validations_read_ini:
path: "{{ ironic_inspector_conf }}" path: "{{ ironic_inspector_conf }}"
section: firewall section: firewall
key: dnsmasq_interface key: dnsmasq_interface

View File

@ -3,7 +3,7 @@
hiera: name="tripleo_undercloud_conf_file" hiera: name="tripleo_undercloud_conf_file"
- name: Gather undercloud.conf values - name: Gather undercloud.conf values
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: local_interface key: local_interface

View File

@ -6,7 +6,7 @@
- name: Get local_ip value from the undercloud.conf file - name: Get local_ip value from the undercloud.conf file
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: local_ip key: local_ip

View File

@ -14,7 +14,7 @@
- name: Get the Container CLI from the undercloud.conf file - name: Get the Container CLI from the undercloud.conf file
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: container_cli key: container_cli

View File

@ -1,7 +1,7 @@
--- ---
- name: Read the `firewall_driver` value - name: Read the `firewall_driver` value
become: true become: true
ini: validations_read_ini:
path: "{{ nova_conf_path }}" path: "{{ nova_conf_path }}"
section: DEFAULT section: DEFAULT
key: firewall_driver key: firewall_driver

View File

@ -1,7 +1,7 @@
--- ---
- name: Get Ironic Inspector swift auth_url - name: Get Ironic Inspector swift auth_url
become: true become: true
ini: validations_read_ini:
path: "{{ ironic_conf_file }}" path: "{{ ironic_conf_file }}"
section: inspector section: inspector
key: auth_url key: auth_url
@ -9,7 +9,7 @@
- name: Get Ironic Inspector swift password - name: Get Ironic Inspector swift password
become: true become: true
ini: validations_read_ini:
path: "{{ ironic_conf_file }}" path: "{{ ironic_conf_file }}"
section: inspector section: inspector
key: password key: password

View File

@ -1,7 +1,7 @@
--- ---
- name: Get VIF Plugging setting values from nova.conf - name: Get VIF Plugging setting values from nova.conf
become: True become: True
ini: validations_read_ini:
path: "{{ nova_config_file }}" path: "{{ nova_config_file }}"
section: DEFAULT section: DEFAULT
key: "{{ item }}" key: "{{ item }}"
@ -29,7 +29,7 @@
- name: Get auth_url value from neutron.conf - name: Get auth_url value from neutron.conf
become: True become: True
ini: validations_read_ini:
path: "{{ neutron_config_file }}" path: "{{ neutron_config_file }}"
section: nova section: nova
key: auth_url key: auth_url
@ -46,7 +46,7 @@
- name: Get Notify Nova settings values from neutron.conf - name: Get Notify Nova settings values from neutron.conf
become: True become: True
ini: validations_read_ini:
path: "{{ neutron_config_file }}" path: "{{ neutron_config_file }}"
section: DEFAULT section: DEFAULT
key: "{{ item }}" key: "{{ item }}"
@ -64,7 +64,7 @@
- name: Get Tenant Name setting value from neutron.conf - name: Get Tenant Name setting value from neutron.conf
become: True become: True
ini: validations_read_ini:
path: "{{ neutron_config_file }}" path: "{{ neutron_config_file }}"
section: nova section: nova
key: "{{ tenant_name_check }}" key: "{{ tenant_name_check }}"

View File

@ -1,7 +1,7 @@
--- ---
- name: Get Ironic Inspector swift auth_url - name: Get Ironic Inspector swift auth_url
become: true become: true
ini: validations_read_ini:
path: "{{ ironic_inspector_conf_file }}" path: "{{ ironic_inspector_conf_file }}"
section: swift section: swift
key: auth_url key: auth_url
@ -9,7 +9,7 @@
- name: Get Ironic Inspector swift password - name: Get Ironic Inspector swift password
become: true become: true
ini: validations_read_ini:
path: "{{ ironic_inspector_conf_file }}" path: "{{ ironic_inspector_conf_file }}"
section: swift section: swift
key: password key: password

View File

@ -123,7 +123,7 @@
# running the playbook. We assume that all of the hosts are in the same realm, so # running the playbook. We assume that all of the hosts are in the same realm, so
# this is not a problem for now. # this is not a problem for now.
- name: Set fact for IdM/FreeIPA realm - name: Set fact for IdM/FreeIPA realm
ini: validations_read_ini:
path: "/etc/ipa/default.conf" path: "/etc/ipa/default.conf"
section: global section: global
key: realm key: realm

View File

@ -17,7 +17,7 @@
- name: Get novajoin keytab path from join.conf - name: Get novajoin keytab path from join.conf
become: true become: true
ini: validations_read_ini:
path: "{{ joinconf_location }}" path: "{{ joinconf_location }}"
section: DEFAULT section: DEFAULT
key: keytab key: keytab
@ -27,7 +27,7 @@
- name: Get novajoin server port from join.conf - name: Get novajoin server port from join.conf
become: true become: true
ini: validations_read_ini:
path: "{{ joinconf_location }}" path: "{{ joinconf_location }}"
section: DEFAULT section: DEFAULT
key: join_listen_port key: join_listen_port
@ -37,7 +37,7 @@
- name: Get novajoin server host from join.conf - name: Get novajoin server host from join.conf
become: true become: true
ini: validations_read_ini:
path: "{{ joinconf_location }}" path: "{{ joinconf_location }}"
section: DEFAULT section: DEFAULT
key: join_listen key: join_listen

View File

@ -16,7 +16,7 @@
- name: Get novajoin keytab path from join.conf - name: Get novajoin keytab path from join.conf
become: true become: true
ini: validations_read_ini:
path: "{{ joinconf_location }}" path: "{{ joinconf_location }}"
section: DEFAULT section: DEFAULT
key: keytab key: keytab
@ -26,7 +26,7 @@
- name: Get novajoin server port from join.conf - name: Get novajoin server port from join.conf
become: true become: true
ini: validations_read_ini:
path: "{{ joinconf_location }}" path: "{{ joinconf_location }}"
section: DEFAULT section: DEFAULT
key: join_listen_port key: join_listen_port
@ -36,7 +36,7 @@
- name: Get novajoin server host from join.conf - name: Get novajoin server host from join.conf
become: true become: true
ini: validations_read_ini:
path: "{{ joinconf_location }}" path: "{{ joinconf_location }}"
section: DEFAULT section: DEFAULT
key: join_listen key: join_listen

View File

@ -10,7 +10,7 @@
- name: Get the Container CLI from the undercloud.conf file (stein+) - name: Get the Container CLI from the undercloud.conf file (stein+)
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: container_cli key: container_cli

View File

@ -7,7 +7,7 @@
- name: Verify that nameservers are set in undercloud.conf - name: Verify that nameservers are set in undercloud.conf
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: undercloud_nameservers key: undercloud_nameservers
@ -56,7 +56,7 @@
- name: Get domain as set in undercloud.conf - name: Get domain as set in undercloud.conf
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: overcloud_domain_name key: overcloud_domain_name
@ -92,7 +92,7 @@
- name: Get enable_novajoin flag from undercloud.conf - name: Get enable_novajoin flag from undercloud.conf
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: enable_novajoin key: enable_novajoin

View File

@ -18,7 +18,7 @@ Role Variables
Dependencies Dependencies
------------ ------------
- 'ini' custom plugin - 'validations_read_ini' custom plugin
Example Playbook Example Playbook
---------------- ----------------

View File

@ -1,7 +1,7 @@
--- ---
- name: Check the services for debug flag - name: Check the services for debug flag
become: True become: True
ini: validations_read_ini:
path: "{{ item }}" path: "{{ item }}"
section: DEFAULT section: DEFAULT
key: debug key: debug

View File

@ -5,7 +5,7 @@
- name: Get the Container CLI from the undercloud.conf file - name: Get the Container CLI from the undercloud.conf file
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: container_cli key: container_cli

View File

@ -6,7 +6,7 @@
- name: Get the Container CLI from the undercloud.conf file - name: Get the Container CLI from the undercloud.conf file
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: container_cli key: container_cli

View File

@ -5,7 +5,7 @@
- name: Get the Container CLI from the undercloud.conf file - name: Get the Container CLI from the undercloud.conf file
become: true become: true
ini: validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}" path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT section: DEFAULT
key: container_cli key: container_cli

View File

@ -13,17 +13,17 @@
# under the License. # under the License.
""" """
test_ini test_validations_read_ini
---------------------------------- ----------------------------------
Tests for `ini` module. Tests for `validations_read_ini` module.
""" """
import os import os
import tempfile import tempfile
import library.ini as validation import library.validations_read_ini as validation
from tripleo_validations.tests import base 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): 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) msg = validation.check_file('non/existing/path', False)
self.assertEqual("Could not open the ini file: 'non/existing/path'", self.assertEqual("Could not open the ini file: 'non/existing/path'",
msg) msg)
def test_check_file_ignore_missing(self): 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) msg = validation.check_file('non/existing/path', True)
self.assertEqual("Could not open the ini file: 'non/existing/path'", self.assertEqual("Could not open the ini file: 'non/existing/path'",
msg) msg)
def test_check_file_valid_path(self): 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() tmpfile = self.create_tmp_ini()
tmp_name = os.path.relpath(tmpfile.name) tmp_name = os.path.relpath(tmpfile.name)
@ -72,7 +72,7 @@ class TestIni(base.TestCase):
self.assertEqual('', msg) self.assertEqual('', msg)
def test_get_result_invalid_format(self): 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() tmpfile = self.create_tmp_ini()
tmp_name = os.path.relpath(tmpfile.name) tmp_name = os.path.relpath(tmpfile.name)
@ -87,7 +87,7 @@ class TestIni(base.TestCase):
self.assertIsNone(value) self.assertIsNone(value)
def test_get_result_key_not_found(self): 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() tmpfile = self.create_tmp_ini()
tmp_name = os.path.relpath(tmpfile.name) tmp_name = os.path.relpath(tmpfile.name)
@ -102,7 +102,7 @@ class TestIni(base.TestCase):
self.assertIsNone(value) self.assertIsNone(value)
def test_get_result_key_not_found_with_default(self): 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() tmpfile = self.create_tmp_ini()
tmp_name = os.path.relpath(tmpfile.name) tmp_name = os.path.relpath(tmpfile.name)
@ -119,7 +119,7 @@ class TestIni(base.TestCase):
self.assertEqual(value, 'foo') self.assertEqual(value, 'foo')
def test_get_result_ok(self): 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() tmpfile = self.create_tmp_ini()
tmp_name = os.path.relpath(tmpfile.name) tmp_name = os.path.relpath(tmpfile.name)