Skip to content

Instantly share code, notes, and snippets.

@miticojo
Created November 23, 2017 16:17
Show Gist options
  • Save miticojo/0d2555f3cda804a21da790ef6dbe66dc to your computer and use it in GitHub Desktop.
Save miticojo/0d2555f3cda804a21da790ef6dbe66dc to your computer and use it in GitHub Desktop.
Ansible Satellite machine deploy through HP ILO drive
- 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