Make Ansible module use /etc/ansible/hosts instead of IP address

mr.zog asked:

I have this Dell iDRAC management module I’m trying to use.

For some bizarre reason it seems to demand an IP address instead of a respecting the hosts: directive. Here’s the example I have been given:

- hosts: idracs
  connection: local
  name: Check LC Ready Status
  gather_facts: False

  tasks:
  - name: Check LC Ready Status
    dellemc_get_lcstatus:
       idrac_ip:   "{{ idrac_ip }}"
       idrac_user: "{{ idrac_user }}"
       idrac_pwd:  "{{ idrac_pwd }}"

I can’t see how to make idrac_ip into a variable. Is /etc/ansible/hosts what I should be using or should I create another(different) inventory object?

My answer:


As far as I can tell you need to define these facts for each host yourself.

It appears you’re using the Dell EMC OpenManage Ansible modules. The way these examples are designed, they appear to expect the variables to come from host facts. So you can just define host_vars for each host. For example, you might create host_vars/myserver.example.com/idrac.yml:

idrac_ip: 10.208.35.6
idrac_user: root
idrac_pw: calvin

Of course, you could get the variables elsewhere for some of the other operations you might perform, e.g. from static facts set on each host or from a dynamic inventory script, but this should get you started.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.