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

Bugfix/apt repository #859

Merged
merged 3 commits into from
Aug 13, 2012
Merged
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
13 changes: 7 additions & 6 deletions library/apt_repository
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
import platform

APT = "/usr/bin/apt-get"
ADD_APT_REPOSITORY = None


def _find_binary():
def _find_binary(module):
binaries = ['/usr/bin/add-apt-repository']

for e in binaries:
Expand All @@ -48,19 +47,21 @@ def _run(cmd):


def main():
add_apt_repository = None

arg_spec = dict(
repo=dict(required=True),
state=dict(default='present', choices=['present', 'absent'])
)

module = AnsibleModule(argument_spec=arg_spec)

ADD_APT_REPOSITORY = _find_binary()
add_apt_repository = _find_binary(module)

repo = module.params['repo']
state = module.params['state']

rc, out, err = _run('%s %s --remove' % (ADD_APT_REPOSITORY, repo))
rc, out, err = _run('%s "%s" --remove' % (add_apt_repository, repo))
existed = 'Error' not in out

if state == 'absent':
Expand All @@ -69,9 +70,9 @@ def main():
else:
module.exit_json(changed=True, repo=repo, state=state)

cmd = '%s %s' % (ADD_APT_REPOSITORY, repo)
cmd = '%s "%s"' % (add_apt_repository, repo)

if float(platform.dist()[1]) >= 11.10:
if platform.dist()[0] == 'debian' or float(platform.dist()[1]) >= 11.10:
cmd = cmd + ' -y'

rc, out, err = _run(cmd)
Expand Down