-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
97 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" | ||
Run repoclosure on a set of repositories | ||
""" | ||
|
||
from subprocess import check_output, CalledProcessError, STDOUT | ||
from ansible.module_utils.basic import AnsibleModule | ||
|
||
|
||
def main(): | ||
""" | ||
Run repoclosure on a set of repositories | ||
""" | ||
module = AnsibleModule( | ||
argument_spec=dict( | ||
config=dict(type='str', required=True), | ||
check=dict(type='list', required=True), | ||
additional_repos=dict(type='list', required=False, default=[]), | ||
lookaside=dict(type='list', required=False, default=[]), | ||
) | ||
) | ||
|
||
config = module.params['config'] | ||
check = module.params['check'] | ||
additional_repos = module.params['additional_repos'] | ||
lookaside = module.params['lookaside'] | ||
|
||
command = [ | ||
'dnf', | ||
'repoclosure', | ||
'--refresh', | ||
'--newest', | ||
'--config', | ||
config | ||
] | ||
|
||
for name in check: | ||
command.extend(['--check', name]) | ||
|
||
for repo in additional_repos: | ||
command.extend(['--repofrompath', f"{repo['name']},{repo['url']}"]) | ||
|
||
for repo in lookaside: | ||
command.extend(['--repo', repo]) | ||
|
||
try: | ||
output = check_output(command, universal_newlines=True, stderr=STDOUT) | ||
except CalledProcessError as error: | ||
module.fail_json(msg='Repoclosure failed', command=' '.join(command), output=error.output) | ||
|
||
module.exit_json(changed=False, output=output) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters