Created
November 23, 2017 16:17
-
-
Save miticojo/0d2555f3cda804a21da790ef6dbe66dc to your computer and use it in GitHub Desktop.
Ansible Satellite machine deploy through HP ILO drive
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
| - hosts: targets | |
| gather_facts: no | |
| tasks: | |
| - hpilo_facts: | |
| host: "{{ilo_ip}}" | |
| login: "{{ilo_user}}" | |
| password: "{{ilo_pass}}" | |
| delegate_to: localhost | |
| register: ilo_facts | |
| tags: ilo_facts | |
| - debug: var=ilo_facts.ansible_facts.hw_eth0.macaddress | |
| - command: | | |
| hammer host create \ | |
| --build yes \ | |
| --location "{{sat_location}}" \ | |
| --organization {{sat_org}} \ | |
| --hostgroup-id {{sat_hostgroup}} \ | |
| --ip {{ lookup('dig', inventory_hostname)}} \ | |
| --mac "{{ilo_facts.ansible_facts.hw_eth0.macaddress}}" \ | |
| --interface "name=eth0,type=interface,ip={{ lookup('dig', inventory_hostname)}},primary=true,managed=true,provision=true" \ | |
| --partition-table-id {{sat_partition_table}} | |
| --name {{inventory_hostname}} | |
| delegate_to: "{{sat_host}}" | |
| register: hammer_host_creation | |
| tags: sat_creation | |
| failed_when: not "Name has already been taken" in hammer_host_creation.stderr and hammer_host_creation.rc != 0 | |
| - command: hammer bootdisk host --host {{inventory_hostname}} --file /var/www/ks/{{inventory_hostname}}.iso --force | |
| delegate_to: "{{sat_host}}" | |
| tags: sat_bootdisk | |
| - name: Shutdown | |
| hpilo_boot: | |
| host: "{{ilo_ip}}" | |
| login: "{{ilo_user}}" | |
| password: "{{ilo_pass}}" | |
| state: poweroff | |
| delegate_to: localhost | |
| - pause: | |
| seconds: 10 | |
| - name: Boot from image | |
| hpilo_boot: | |
| host: "{{ilo_ip}}" | |
| login: "{{ilo_user}}" | |
| password: "{{ilo_pass}}" | |
| image: "http://{{ lookup('dig', sat_host) }}/ks/{{inventory_hostname}}.iso" | |
| media: cdrom | |
| delegate_to: localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment