HewlettPackard / oneview-ansible-collection

Ansible Collection and Sample Playbooks for HPE OneView
Apache License 2.0
25 stars 22 forks source link

Adding Multiple Rack-mounted Servers #129

Closed peterdolinski closed 3 years ago

peterdolinski commented 3 years ago

I am trying to create server hardware for multiple servers using the "add multiple rack-mounted servers" tasks in "oneview_server_hardware" role. I am not sure how and where to specify the multiple iLo IPs or a range of IPs so that the playbook can create multiple hardware server instances in OneView at one time? . I have to work with iLo IPs because my servers are DLs, not blades. I see that the mpHostsAndRanges takes the multiple_hosts veritable from the /defaults/main.yml file.

Any suggestions will be appreciated!

Thanks, Peter

VenkateshRavula commented 3 years ago

Hi @peterdolinski , We have provided an example task to add multiple DL servers using list of iLO ips in oneview_server_hardware role. (https://github.com/HewlettPackard/oneview-ansible-collection/blob/master/roles/oneview_server_hardware/tasks/main.yml#L38-L50)

For this to work you need to provide necessary info in below file. https://github.com/HewlettPackard/oneview-ansible-collection/blob/master/roles/oneview_server_hardware/defaults/main.yml#L6-L9

server_hardware_username: "user1"
server_hardware_password: "paswd"
multiple_hosts:
  - "1.2.3.4"
  - "1.2.3.5"
  - "1.2.3.6"
nabhajit-ray commented 3 years ago

Hi @peterdolinski , Please let us know if the solution is working for you. We will be closing the issue. You can re open if it is not working

peterdolinski commented 3 years ago

Hello nabhajit-ray and Venkatesh Ravula,

I was on vacation and didn't respond on time, for which I am sorry.

No, for some reason it doesn't work. I copied and renamed the role so that I don't change the original one.

So, below is my config: ***tasks/main.yml

This task available only with OneView API version >= 600.

***defaults/main.yml

defaults file for oneview_server_hardware

config: "~/.ansible/collections/ansible_collections/hpe/oneview/roles/ov_multiple_servers_hardware/files/oneview_config.json" contents: "{{lookup('file', config)}}" server_hardware_username: "admin" server_hardware_password: "password" multiple_hosts:

connection to oneview appliance oneview_config.json

"ip": "1.2.3.4", "credentials": { "userName": "Administrator", "authLoginDomain": "", "password": "local_password" }, "api_version": 2800 }

***Output [WARNING]: running playbook inside collection hpe.oneview

PLAY [all] **

TASK [Gathering Facts] ** ok: [localhost]

TASK [ov_multiple_servers_hardware : Add multiple rack-mount servers] *** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 9 column 3 (char 191) fatal: [localhost -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1628032039.0732534-259626770534831/AnsiballZ_oneview_server_hardware.py\", line 102, in \n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1628032039.0732534-259626770534831/AnsiballZ_oneview_server_hardware.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1628032039.0732534-259626770534831/AnsiballZ_oneview_server_hardware.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.hpe.oneview.plugins.modules.oneview_server_hardware', init_globals=None, run_name='main', alter_sys=True)\n File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_oneview_server_hardware_payload_aqkrme_0/ansible_oneview_server_hardware_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_hardware.py\", line 427, in \n File \"/tmp/ansible_oneview_server_hardware_payload_aqkrme_0/ansible_oneview_server_hardware_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_hardware.py\", line 423, in main\n File \"/tmp/ansible_oneview_server_hardware_payload_aqkrme_0/ansible_oneview_server_hardware_payload.zip/ansible_collections/hpe/oneview/plugins/modules/oneview_server_hardware.py\", line 297, in init\n File \"/tmp/ansible_oneview_server_hardware_payload_aqkrme_0/ansible_oneview_server_hardware_payload.zip/ansible_collections/hpe/oneview/plugins/module_utils/oneview.py\", line 546, in init\n File \"/tmp/ansible_oneview_server_hardware_payload_aqkrme_0/ansible_oneview_server_hardware_payload.zip/ansible_collections/hpe/oneview/plugins/module_utils/oneview.py\", line 584, in _create_oneview_client\n File \"/usr/local/lib/python3.8/dist-packages/hpeOneView/oneview_client.py\", line 225, in from_json_file\n config = json.load(json_data)\n File \"/usr/lib/python3.8/json/init.py\", line 293, in load\n return loads(fp.read(),\n File \"/usr/lib/python3.8/json/init.py\", line 357, in loads\n return _default_decoder.decode(s)\n File \"/usr/lib/python3.8/json/decoder.py\", line 337, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n File \"/usr/lib/python3.8/json/decoder.py\", line 353, in raw_decode\n obj, end = self.scan_once(s, idx)\njson.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 9 column 3 (char 191)\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP ** localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

I appreciate your feedback!!

Thank you,

Peter


From: nabhajit-ray @.> Sent: Monday, July 26, 2021 10:06 PM To: HewlettPackard/oneview-ansible-collection @.> Cc: Peter S. Dolinski @.>; Mention @.> Subject: Re: [HewlettPackard/oneview-ansible-collection] Adding Multiple Rack-mounted Servers (#129)

Hi @peterdolinskihttps://github.com/peterdolinski , Please let us know if the solution is working for you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/HewlettPackard/oneview-ansible-collection/issues/129#issuecomment-887212315, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANZDGCJ2A5T72PFS5IKEU6LTZY5GPANCNFSM5AY4AWAA.

chebroluharika commented 3 years ago

Hi @peterdolinski, After looking into your oneview_config.json in above comment, we can see that opening bracket in first line is missing that's because an error was thrown saying json structure is invalid in config file. Please refer https://github.com/HewlettPackard/oneview-ansible-collection/blob/master/roles/oneview_server_hardware/files/oneview_config.json and pass credentials accordingly. And also feel free to revert back if you see any issues even after giving proper json credentials structure. Thanks.

peterdolinski commented 3 years ago

Hello everybody! I think the usage of the multiple iLo Ips against the creation of the hardware profile is working now. I was wondering, though how, and where I could incorporate a prompt to query the facts of just one hardware or server profile. Another use case is to point the playbook to a file with multiple server or hardware profiles to get facts or create profiles.

Also, how would you use the scopes to query the facts of the servers in a particular scope? I manually created a scope in the GUI and added 10 servers in it. So, now I would like to run a play to get facts out of them, for example, the WWPNs of the HBAs.

Thank you so much! I appreciate your knowledge!