---
- hosts: localhost
gather_facts: false
vars:
ilo_host: "192.168.0.10" # IP address / hostname of the iLO interface
ilo_user: "xxxxx" # username for the user to log into the iLO
ilo_password: "xxxxxx" # fetch from vault or other secret storage
hpilo_cli_cmd: "hpilo_cli {{ ilo_host }} --json --login='{{ ilo_user }}' --password='{{ ilo_password }}'"
tasks:
- name: Get current power status
command: "{{ hpilo_cli_cmd }} get_host_power_status"
register: hpilo_cli_get_host_power_status
- name: Record power status
set_fact:
power_status: "{% if 'ON' in hpilo_cli_get_host_power_status.stdout %}ON{% else %}OFF{% endif %}"
- name: Power on server - if it is powered down
command: "{{hpilo_cli_cmd}} press_pwr_btn"
when: power_status != "ON"
- name: Reboot server - if it is powered up
command: "{{hpilo_cli_cmd}} cold_boot_server"
when: power_status == "ON"
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/575de21c-8c32-448a-9f6c-f0567d1157ba%40googlegroups.com.
virtualenv venv
. venv/bin/activate
pip install ansible python-hpilo
ansible-playbook -i "localhost," -c local playbook.yml
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d843e73d-cca7-4896-b435-0998e84d372f%40googlegroups.com.