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

Cleanup release_fetch #40

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
22 changes: 11 additions & 11 deletions iocage.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
args:
description:
- Additional arguments.
type: dict
type: str
default: ""
user:
description:
- I(user) who runs the command I(cmd).
Expand All @@ -77,7 +78,7 @@
type: str
release:
description:
- Specify which RELEASE to fetch, update, or create a jail.
- Specify which RELEASE to fetch, update, or create a jail from.
type: str
update:
description:
Expand Down Expand Up @@ -389,7 +390,6 @@ def release_fetch(module, iocage_path, update=False, release="NO-RELEASE", compo
if _component != "":
args += f" -F {_component}"
cmd = f"{iocage_path} fetch -r {release} {args}"
rc = 1
rc, out, err = module.run_command(to_bytes(cmd, errors='surrogate_or_strict'),
errors='surrogate_or_strict')
if not rc == 0:
Expand All @@ -403,7 +403,7 @@ def release_fetch(module, iocage_path, update=False, release="NO-RELEASE", compo
_changed = True
_msg = f"Release {release} would have been fetched."

return release, _changed, _msg
return _changed, _msg


def jail_restart(module, iocage_path, name):
Expand Down Expand Up @@ -682,17 +682,17 @@ def run_module():
default="facts",
choices=["basejail", "thickjail", "template", "present", "cloned", "started",
"stopped", "restarted", "fetched", "exec", "pkg", "exists", "absent",
"set", "facts"],),
"set", "facts"]),
name=dict(type='str'),
pkglist=dict(type='path'),
properties=dict(type='dict'),
args=dict(type='dict'),
args=dict(type='str', default=""),
user=dict(type='str', default="root"),
cmd=dict(type='str'),
clone_from=dict(type='str'),
release=dict(type='str'),
update=dict(type='bool', default=False,),
components=dict(type='list', elements='path', aliases=["files", "component"],),)
update=dict(type='bool', default=False),
components=dict(type='list', elements='path', aliases=["files", "component"]),)

module = AnsibleModule(argument_spec=module_args,
supports_check_mode=True)
Expand Down Expand Up @@ -810,7 +810,7 @@ def run_module():

elif p["state"] == "fetched":
if update or release not in facts["iocage_releases"]:
rel, changed, _msg = release_fetch(module, iocage_path, update, release, components, args)
changed, _msg = release_fetch(module, iocage_path, update, release, components, args)
msgs.append(_msg)
facts["iocage_releases"] = _get_iocage_facts(module, iocage_path, "releases")
if release not in facts["iocage_releases"] or update:
Expand All @@ -833,7 +833,7 @@ def run_module():
# jail_exists = False

if p["state"] != "cloned" and release not in facts["iocage_releases"]:
release, _release_changed, _release_msg = release_fetch(module, iocage_path, update, release, components, args)
_release_changed, _release_msg = release_fetch(module, iocage_path, update, release, components, args)
if _release_changed:
facts["iocage_releases"] = _get_iocage_facts(module, iocage_path, "releases")
msgs.append(_release_msg)
Expand Down Expand Up @@ -880,7 +880,7 @@ def run_module():

if p["update"]:
if release not in facts["iocage_releases"]:
release, _release_changed, _release_msg = release_fetch(module, iocage_path, update, release, components, args)
_release_changed, _release_msg = release_fetch(module, iocage_path, update, release, components, args)
if _release_changed:
_msg += _release_msg
facts["iocage_releases"] = _get_iocage_facts(module, iocage_path, "releases")
Expand Down