Created
February 24, 2016 13:39
-
-
Save marianschmotzer/e3b22d1219f2d5469262 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Add the each distro/profile pair only if the distro doesn't already exist | |
- name: check distro exists in cobbler | |
with_items: distros | |
command: cobbler distro report --name={{ item.name }} | |
register: distro_result | |
ignore_errors: true | |
failed_when: False | |
changed_when: False | |
when: distros is defined | |
- debug: msg="Distro watch {{ distro_result.rc }}" | |
- name: add distro/profile pairs to cobbler | |
shell: > | |
(mkdir -p {{ item.path | quote }} | |
&& mount -t iso9660 -o loop,ro {{ item.file | quote }} {{ item.path | quote }} | |
&& cobbler import --path={{ item.path | quote }} --name={{ item.name | quote }} --arch={{ item.arch | quote }} {% if item.kickstart is defined %}--kickstart={{ item.kickstart | quote }}{% endif %} | |
&& umount {{ item.path | quote }}) | |
with_items: distros | |
when: distros is defined and distro_result.rc == 1 | |
notify: | |
- restart cobbler | |
- wait for cobbler | |
- sync cobbler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TASK: [ansible-cobbler | check distro exists in cobbler] **********************
ok: [os-util1] => (item={'url': 'http://releases.ubuntu.com/14.04.4/ubuntu-14.04.4-server-amd64.iso', 'path': '/root/iso/ubuntu-server-14.04/', 'arch': 'x86_64', 'name': 'ubuntu-server-14.04.4', 'file': '/root/iso/ubuntu-server-14.04.iso'}) => {"changed": false, "cmd": ["cobbler", "distro", "report", "--name=ubuntu-server-14.04.4"], "delta": "0:00:00.141062", "end": "2016-02-24 13:44:17.478234", "failed": false, "failed_when_result": false, "item": {"arch": "x86_64", "file": "/root/iso/ubuntu-server-14.04.iso", "name": "ubuntu-server-14.04.4", "path": "/root/iso/ubuntu-server-14.04/", "url": "http://releases.ubuntu.com/14.04.4/ubuntu-14.04.4-server-amd64.iso"}, "rc": 1, "start": "2016-02-24 13:44:17.337172", "stderr": "", "stdout": "No distro found: ubuntu-server-14.04.4", "stdout_lines": ["No distro found: ubuntu-server-14.04.4"], "warnings": []}
TASK: [ansible-cobbler | debug msg="Distro watch {{ distro_result }}"] ********
ok: [os-util1] => {
"msg": "Distro watch {'msg': 'All items completed', 'changed': False, 'results': [{'stdout': 'No distro found: ubuntu-server-14.04.4', 'changed': False, 'end': '2016-02-24 13:44:17.478234', 'item': {'url': 'http://releases.ubuntu.com/14.04.4/ubuntu-14.04.4-server-amd64.iso', 'path': '/root/iso/ubuntu-server-14.04/', 'arch': 'x86_64', 'name': 'ubuntu-server-14.04.4', 'file': '/root/iso/ubuntu-server-14.04.iso'}, 'cmd': ['cobbler', 'distro', 'report', '--name=ubuntu-server-14.04.4'], 'rc': 1, 'failed': False, 'stderr': u'', 'delta': '0:00:00.141062', 'invocation': {'module_name': u'command', 'module_complex_args': {}, 'module_args': u'cobbler distro report --name=ubuntu-server-14.04.4'}, 'stdout_lines': ['No distro found: ubuntu-server-14.04.4'], 'failed_when_result': False, 'start': '2016-02-24 13:44:17.337172', 'warnings': []}]}"
}