Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added autload parameter #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion library/augtool
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ options:
- Either a list of augtool commands, or else a newline-separated
list of commands
required: true
autoload:
description:
- Should augtool load lenses by default or it will be provided
as one of commands (or it will fail misserably :) )
required: false
choices: [yes, no]
default: yes
backup:
description:
- Whether or not to make a backup of the files changed (passes
Expand All @@ -56,6 +63,19 @@ args:
set \$vsftpd/xferlog_std_format NO
set \$vsftpd/log_ftp_protocol YES

# do backup, and do not autoload all lenses just specific for dovecot
# this will speed up augtool tenfold
action: augtool
args:
backup: true
autoload: false
commands: |
set /augeas/load/Dovecot/lens Dovecot.lns
set /augeas/load/Dovecot/incl /etc/dovecot/conf.d/10-master.conf
load
rm /files/etc/dovecot/conf.d/10-master.conf/service[8]/
save

# Or provide the commands as a list.
action: augtool
args:
Expand Down Expand Up @@ -84,7 +104,8 @@ def main():
module = AnsibleModule(
argument_spec=dict(
commands=dict(required=True),
backup=dict(choices=BOOLEANS, default=True)
backup=dict(type='bool', default=True),
autoload=dict(type='bool', default=True)
),
supports_check_mode=True,
)
Expand All @@ -94,10 +115,13 @@ def main():
if isinstance(commands, list):
commands = "\n".join(commands)
backup = module.boolean(params["backup"])
autoload = module.boolean(params["autoload"])

cmd = ["augtool"]
if backup:
cmd.append("--backup")
if not autoload:
cmd.append("--noautoload")
if module.check_mode:
commands += "\nset /augeas/save noop"
commands += "\nsave\nprint /augeas//error\n"
Expand Down