PEP8 fixes: Ansible system module and playbook base.py (#32322)

* Ansible files module sanity pep8 fixes

* Ansible system module and playbook base.py

* Undo empty lines not required by sanity checks

* Undo empty lines not required by sanity checks

* Undo empty lines not required by sanity checks

* Undo empty lines not required by sanity checks

* Undo empty lines not required by sanity checks

* Undo empty lines not required by sanity checks

* Undo empty lines not required by sanity checks

* Undo empty lines not required by sanity checks

* Undo empty lines not required by sanity checks

* Undo empty lines not required by sanity checks

* Undo empty lines not required by sanity checks

* Various changes

* Various changes

* Various changes

* Various changes

* Undo blank lines not required by sanity checks

* Various changes

* Various changes

* Various changes

* Various changes

* Various changes

* Undo blank line changes not required by sanity checks

* Various changes

* Various changes

* Various changes

* Various changes

* Various changes

* Missing piece after merge

* Blank lines

* Blank line

* Line too long

* Fix typo

* Unnecessary quotes

* Fix example error
This commit is contained in:
Yadnyawalkya Tale
2017-11-07 08:38:59 +00:00
committed by Dag Wieers
parent a5da2e44a1
commit a2d34e914e
31 changed files with 878 additions and 1004 deletions

View File

@@ -1,25 +1,22 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2014, Brian Coca <briancoca+ansible@gmail.com>
# Copyright: (c) 2014, Brian Coca <briancoca+ansible@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = '''
---
module: debconf
short_description: Configure a .deb package
description:
- Configure a .deb package using debconf-set-selections. Or just query
existing selections.
- Configure a .deb package using debconf-set-selections. Or just query existing selections.
version_added: "1.6"
notes:
- This module requires the command line debconf tools.
@@ -33,60 +30,54 @@ options:
description:
- Name of package to configure.
required: true
default: null
aliases: ['pkg']
aliases: [ pkg ]
question:
description:
- A debconf configuration setting
required: false
default: null
aliases: ['setting', 'selection']
- A debconf configuration setting.
aliases: [ selection, setting ]
vtype:
description:
- The type of the value supplied.
- C(seen) was added in 2.2.
required: false
default: null
choices: [string, password, boolean, select, multiselect, note, error, title, text, seen]
choices: [ boolean, error, multiselect, note, password, seen, select, string, text, title, text ]
value:
description:
- Value to set the configuration to
required: false
default: null
aliases: ['answer']
- Value to set the configuration to.
aliases: [ answer ]
unseen:
description:
- Do not set 'seen' flag when pre-seeding
required: false
- Do not set 'seen' flag when pre-seeding.
type: bool
default: False
author: "Brian Coca (@bcoca)"
author:
- Brian Coca (@bcoca)
'''
EXAMPLES = '''
# Set default locale to fr_FR.UTF-8
- debconf:
- name: Set default locale to fr_FR.UTF-8
debconf:
name: locales
question: locales/default_environment_locale
value: fr_FR.UTF-8
vtype: select
# set to generate locales:
- debconf:
- name: set to generate locales
debconf:
name: locales
question: locales/locales_to_be_generated
value: en_US.UTF-8 UTF-8, fr_FR.UTF-8 UTF-8
vtype: multiselect
# Accept oracle license
- debconf:
- name: Accept oracle license
debconf:
name: oracle-java7-installer
question: shared/accepted-oracle-license-v1-1
value: true
vtype: select
# Specifying package you can register/return the list of questions and current values
- debconf:
- name: Specifying package you can register/return the list of questions and current values
debconf:
name: tzdata
'''
@@ -104,13 +95,12 @@ def get_selections(module, pkg):
for line in out.splitlines():
(key, value) = line.split(':', 1)
selections[ key.strip('*').strip() ] = value.strip()
selections[key.strip('*').strip()] = value.strip()
return selections
def set_selection(module, pkg, question, vtype, value, unseen):
setsel = module.get_bin_path('debconf-set-selections', True)
cmd = [setsel]
if unseen:
@@ -125,27 +115,26 @@ def set_selection(module, pkg, question, vtype, value, unseen):
return module.run_command(cmd, data=data)
def main():
def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(required=True, aliases=['pkg'], type='str'),
question=dict(required=False, aliases=['setting', 'selection'], type='str'),
vtype=dict(required=False, type='str', choices=['string', 'password', 'boolean', 'select', 'multiselect', 'note', 'error', 'title',
'text', 'seen']),
value=dict(required=False, type='str', aliases=['answer']),
unseen=dict(required=False, type='bool'),
name=dict(type='str', required=True, aliases=['pkg']),
question=dict(type='str', aliases=['selection', 'setting']),
vtype=dict(type='str', choices=['boolean', 'error', 'multiselect', 'note', 'password', 'seen', 'select', 'string', 'text', 'title']),
value=dict(type='str', aliases=['answer']),
unseen=dict(type='bool'),
),
required_together=(['question','vtype', 'value'],),
required_together=(['question', 'vtype', 'value'],),
supports_check_mode=True,
)
#TODO: enable passing array of options and/or debconf file from get-selections dump
pkg = module.params["name"]
# TODO: enable passing array of options and/or debconf file from get-selections dump
pkg = module.params["name"]
question = module.params["question"]
vtype = module.params["vtype"]
value = module.params["value"]
unseen = module.params["unseen"]
vtype = module.params["vtype"]
value = module.params["value"]
unseen = module.params["unseen"]
prev = get_selections(module, pkg)
@@ -156,7 +145,7 @@ def main():
if vtype is None or value is None:
module.fail_json(msg="when supplying a question you must supply a valid vtype and value")
if not question in prev or prev[question] != value:
if question not in prev or prev[question] != value:
changed = True
if changed:
@@ -165,7 +154,7 @@ def main():
if rc:
module.fail_json(msg=e)
curr = { question: value }
curr = {question: value}
if question in prev:
prev = {question: prev[question]}
else: