Sometimes there might be a key in configfile, that should be empty but
defined correctly. This patch fixes such behaviour and adds testing.
Change-Id: I693bc3a2aade7015d0465583001962df4ba53443
The config_template comment parser will now respect all comments in
INI files, as they are written. This will ensure spacing, paragraphs,
and other comments bits that may be in an INI file remain intact,
even when overriding options and sections. With this feature we'll
now be able to insert options in OSLO config generated files without
truncating or making a mess of the file structure.
This is an internal enhancement and requires no change from the
operator or from within any ansible task. To ensure enhanced comments
are working, new tests have been added which will run though all of
the `config_template` INI file functions using a mock service file.
Existing tests for the old comment structure has been removed.
This includes tests that were running redundant tasks for file
diffs or expected the only style, merged, comment layout. All of the
tests have been broken out into descriptive task files. This was
largely done for readability. It was difficult to see what tests
we had and how I needed to extend them to test the enhanced comments
functionality given the INI type tests were all thoughout the
`tests/test-common-tasks.yml`. Now that the files have been broken
out developers will easily be able to audit our tests making it
simple to extend.
Change-Id: Ia6cdc215c35fa9ac45b718c211616a9887a74e37
Signed-off-by: Kevin Carter <kecarter@redhat.com>
The config template action plugin assumes that the local node is
supplying a configuration file that will be used to copy content
to a target node. This change gives the module the ability to
change configuration files on target nodes using all remote
sources. The new boolean option, `remote_src` has been added to
enable or disable this functionality. When enabled, the module
will retrieve content from the target node and load it as
"user_content". By pre-loading it in the user content the
module will function normally without any major structural
changes or performance impact.
Change-Id: Id9c7e16fb935c2da0b32b7cf53449f68bd1e9c89
Signed-off-by: Kevin Carter <kecarter@redhat.com>
Added a flag called yml_multilines which when used will not split on
lines that have a newline UNLESS they have a comma.
Change-Id: I90364403e215a67b320dfc7e67a85d47c774e634
Partial-Bug: #1819974
Incorporate the musltistropt test cases from openstack-ansible-plugins
/tests/test-config_template.yml excluded from ansible-config_template
Change-Id: I57c4eb3e1c879671facfa4564f78869961a4e9f2
Closes-Bug: #1815620
The default section in an ini file will always be 'DEFAULT', but for some
configuration files you may want to be able to set this to ensure
another section is at the top. 'global' for example, when working with
fio.
This PR adds the ability to set the section to be at the top, but will
default to 'DEFAULT' so no change will happen to existing tasks running
config_template.
Change-Id: Ifbc0b91aef46f3c2d98e73fdc9ab888244550bab
unicode is nolonger a type in py3 - instead the str type is used for
unicode, and the bytes type would cover the str type from py2.
To avoid having to version the code, we should try to use unicode,
except the NameError and continue as though it is py3 if that fails.
Additionally, this patch adds a test that will fail if you revert the
config_template.py back to it's original in py3.
Closes-bug: 1763422
Change-Id: Ifda972caada27ade2d80f77b3df70568406226ff
When users specificy the 'content' attribute when
using the config_template module, it's possible that
this input can be a dict. This commit handles
dictionary input, and dumps it accordingly based
on 'config_type'
Change-Id: I1f12810ad7ce5746f8938ec9d608c532ba530d58
This is a lookup in case you need to parse a ubuntu repo Packages file
for a list of packages. It's useful in osa if you want to have a mirror
of an ubuntu repo, and output a list of its packages, with their
location and checksum.
You can use the output dict to feed another tool (for example
downloading with aria).
Change-Id: I10ba72f0b64267ae6afe57317e135d782445e934
The default py yaml `safe_dumps` keeps to the yaml spec which states
incremental indentations are not required. Sadly, without the
indentations some consumers of yaml configurations files will break.
This commit adds an incremental indentation dumper to cater for all
yaml configuration consumers.
Change-Id: Ifa5bcc6ff9f0a9cb5e619e62d0356f5d6887ca6e
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
By default a list item in a JSON or YAML format will extend if a its already
defined in the target template and a config_override using a list is being set
for the existing "key".
This change allows that functionality to be toggled on or off. The boolean
option to enable list extension is ``list_extend``.
To maintain the API this feature will remain True by default.
Co-Authored-By: Travis Truman <travis_truman@cable.comcast.com>
Change-Id: I97e06aef2cc778f048f3d6863fe61d10eddb8602
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>