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 documentation to APT module #1128

Merged
merged 3 commits into from
Sep 28, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions hacking/module_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ def html_ify(text):
t = _CONST.sub("<code>" + r"\1" + "</code>", t)
return t

def json_ify(text):

t = _ITALIC.sub("<em>" + r"\1" + "</em>", text)
t = _BOLD.sub("<b>" + r"\1" + "</b>", t)
t = _MODULE.sub("<span class='module'>" + r"\1" + "</span>", t)
t = _URL.sub("<a href='" + r"\1" + "'>" + r"\1" + "</a>", t)
t = _CONST.sub("<code>" + r"\1" + "</code>", t)

return t

def man_ify(text):

t = _ITALIC.sub(r'\\fI' + r"\1" + r"\\fR", text)
Expand Down Expand Up @@ -164,7 +174,7 @@ def main():
p.add_argument("-t", "--type",
action='store',
dest='type',
choices=['html', 'latex', 'man', 'rst'],
choices=['html', 'latex', 'man', 'rst', 'json'],
default='latex',
help="Output type")
p.add_argument("-m", "--module",
Expand Down Expand Up @@ -234,6 +244,9 @@ def main():
env.filters['xline'] = rst_xline
template = env.get_template('rst.j2')
outputname = "%s.rst"
if args.type == 'json':
env.filters['jpfunc'] = json_ify
outputname = "%s.json"

for module in os.listdir(args.module_dir):
if len(args.module_list):
Expand Down Expand Up @@ -267,7 +280,12 @@ def main():
f.close()
doc['extradata'] = extradata

text = template.render(doc)
if args.type == 'json':
doc = { doc['module'] : doc }
text = json.dumps(doc, indent=2)
else:
text = template.render(doc)

if args.output_dir is not None:
f = open(os.path.join(args.output_dir, outputname % module), 'w')
f.write(text)
Expand Down
78 changes: 78 additions & 0 deletions library/apt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,84 @@
# along with this software. If not, see <http://www.gnu.org/licenses/>.
#

DOCUMENTATION = '''
---
module: apt
short_description: Manages apt-packages (such as for Debian/Ubuntu).
description:
- Manages apt-packages (such as for Debian/Ubuntu).
version_added: "0.0.2"
options:
name:
description:
- A package name or package specifier with version, like foo or foo=1.0
required: false
default: null
state:
description:
- Indicate the package state
required: false
default: present
choices: [ "installed", "latest", "remove", "absent", "present" ]
update_cache:
description:
- Run the equivalent of apt-get update before the operation. Can be run as part of the package installation or a seperate step
required: false
default: "no"
choices: [ "yes", "no" ]
purge:
description:
- Will forge purge of configuration files if state is set to 'absent'.
required: false
default: "no"
choices: [ "yes", "no" ]
default_release:
description:
- Corresponds to the -t option for apt and sets pin priorities
required: false
default: null
install_recommends:
description:
- Corresponds to the --no-install-recommends option for apt, default behavior works as apt's default behavior, 'no' does not install recommended packages. Suggested packages are never installed.
required: false
default: "no"
choices: [ "yes", "no" ]
force:
description:
- If ‘yes’, force installs/removes.
required: false
default: "no"
choices: [ "yes", "no" ]
author: Matthew Williams
'''

EXAMPLES = [
"""
- code: apt pkg=foo update-cache=yes
description: Update repositories cache and install 'foo' package
""",
"""
- code: apt pkg=foo state=removed
description: Remove 'foo' package
""",
"""
- code: apt pkg=foo state=installed
description: Install the the package 'foo'
""",
"""
- code: apt pkg=foo=1.00 state=installed
description: Install the version '1.00' of package 'foo'
""",
"""
- code: apt pkg=nginx state=latest default-release=squeeze-backports update-cache=yes
description: Update the repository cache and update package 'ngnix' to latest versione using default release 'squeeze-backport'
""",
"""
- code: apt pkg=openjdk-6-jdk state=latest install-recommends=no
description: Install latest version of 'openjdk-6-jdk' ignoring 'install-recomands'
"""
]

import traceback
# added to stave off future warnings about apt api
import warnings
Expand Down
37 changes: 37 additions & 0 deletions library/apt_repository
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,43 @@
# action: apt_repository repo=ppa:nginx/stable state=present
#

DOCUMENTATION = '''
---
module: apt_repository
short_description: Manages apt repositores (such as for Debian/Ubuntu).
description:
- Manages apt repositores (such as for Debian/Ubuntu).
version_added: "0.7"
options:
repo:
description:
- The repository name/value
required: true
default: null
state:
description:
- The repository state
required: false
default: present
choices: [ "present", "absent" ]
notes:
- This module require 'apt-add-repository' wwill be available on destination server. To ensure this package is available use 'apt' module and install 'python-software-properties' package before use this module.
- This module work only on Ubuntu and unstable Debian, see U(https://github.com/ansible/ansible/pull/1082, this issue)
- A bug in 'apt-add-repository' always add 'deb' and 'deb-src' type for repo (see the U(https://bugs.launchpad.net/ubuntu/+source/software-properties/+bug/987264, issue on lunchpad)), if some repo don't have source (eg: MongoDB repo from 10gen) the system fail on update repositories.
author: Matt Wright
'''

EXAMPLES = [
"""
- code: apt_repository repo=ppa://nginx/stable
description: Add nginx stable repository from PPA
""",
"""
- code: apt_repository repo='deb http://archive.canonical.com/ubuntu hardy partner'
description: Add specified repository into sources.
"""
]

import platform

APT = "/usr/bin/apt-get"
Expand Down