Fix documentation YAML for pkgin module

This commit is contained in:
Michael DeHaan 2013-01-26 12:44:43 -05:00
parent 7c621a987b
commit ae176d5310

24
pkgin
View file

@ -26,29 +26,27 @@ module: pkgin
short_description: Package manager for SmartOS short_description: Package manager for SmartOS
description: description:
- Manages SmartOS packages - Manages SmartOS packages
version_added: "1.0" version_added: "1.0"
options: options:
name: name:
description: description:
- name of package to install/remove - name of package to install/remove
required: true required: true
state: state:
description: description:
- state of the package installed or absent. - state of the package
choices: [ 'present', 'absent' ]
required: false required: false
default: present
author: Shaun Zinck author: Shaun Zinck
notes: [] notes: []
examples: examples:
- code: "pkgin: name=foo state=installed" - code: "pkgin: name=foo state=present"
description: install package foo" description: install package foo"
- code: "pkgin: name=foo state=absent" - code: "pkgin: name=foo state=absent"
description: remove package foo description: remove package foo
- code: "pkgin: name=foo,bar state=absent - code: "pkgin: name=foo,bar state=absent"
description: remove packages foo and bar description: remove packages foo and bar
''' '''
@ -59,9 +57,9 @@ import sys
PKGIN_PATH = "/opt/local/bin/pkgin" PKGIN_PATH = "/opt/local/bin/pkgin"
def query_package(module, name, state="installed"): def query_package(module, name, state="present"):
if state == "installed": if state == "present":
rc, out, err = module.run_command("%s list | grep ^%s" % (PKGIN_PATH, name)) rc, out, err = module.run_command("%s list | grep ^%s" % (PKGIN_PATH, name))
@ -110,16 +108,16 @@ def install_packages(module, packages):
install_c += 1 install_c += 1
if install_c > 0: if install_c > 0:
module.exit_json(changed=True, msg="installed %s package(s)" % (install_c)) module.exit_json(changed=True, msg="present %s package(s)" % (install_c))
module.exit_json(changed=False, msg="package(s) already installed") module.exit_json(changed=False, msg="package(s) already present")
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec = dict(
state = dict(default="installed", choices=["installed","absent"]), state = dict(default="present", choices=["present","absent"]),
name = dict(aliases=["pkg"], required=True))) name = dict(aliases=["pkg"], required=True)))
@ -130,7 +128,7 @@ def main():
pkgs = p["name"].split(",") pkgs = p["name"].split(",")
if p["state"] == "installed": if p["state"] == "present":
install_packages(module, pkgs) install_packages(module, pkgs)
elif p["state"] == "absent": elif p["state"] == "absent":