-
-
Save marianschmotzer/e3b22d1219f2d5469262 to your computer and use it in GitHub Desktop.
# 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 |
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': []}]}"
}
TASK: [ansible-cobbler | create iso directory to hold distro images] **********
ok: [os-util1] => {"changed": false, "gid": 0, "group": "root", "mode": "0755", "owner": "root", "path": "/root/iso", "size": 4096, "state": "directory", "uid": 0}
TASK: [ansible-cobbler | download distro iso files] ***************************
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, "dest": "/root/iso/ubuntu-server-14.04.iso", "gid": 0, "group": "root", "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"}, "mode": "0644", "msg": "file already exists", "owner": "root", "size": 607125504, "state": "file", "uid": 0, "url": "http://releases.ubuntu.com/14.04.4/ubuntu-14.04.4-server-amd64.iso"}
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.124536", "end": "2016-02-24 13:37:11.205570", "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:37:11.081034", "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.rc }}"] *****
fatal: [os-util1] => One or more undefined variables: 'dict object' has no attribute 'rc'
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
ansible-cobbler | wait for cobbler -------------------------------------- 5.07s
ansible-cobbler | install dependencies (apt) ---------------------------- 4.83s
ansible-cobbler | update cobbler signatures ----------------------------- 2.20s
ansible-ntp | Start/stop ntp service ------------------------------------ 1.40s
ansible-cobbler | import cobbler key ------------------------------------ 0.72s
cra-server-prepare | Install default system packages -------------------- 0.38s
cra-server-prepare | ensure openstack kilo repository requirements are installed --- 0.38s
ansible-ntp | Install the required packages in Debian derivatives ------- 0.37s
ansible-cobbler | install cobbler (apt) --------------------------------- 0.37s
cra-server-prepare | Create default admin accounts ---------------------- 0.36s
to retry, use: --limit @/Users/scma/deploy-util-stack.retry
os-util1 : ok=50 changed=3 unreachable=1 failed=0
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.