File: //lib/python3.9/site-packages/ansible_collections/cisco/intersight/playbooks/servers_to_file.yml
---
# Update standalone servers (IMC) in the file
- lineinfile:
path: "{{ filepath }}"
insertafter: "^\\[{{ host_group }}\\]"
regexp: "^{{ item.Name }} "
# Each line of the inventory has the following:
# Name server_moid=<Moid value> model=<Model value> ...
line: "{{ item.Name }} server_moid={{ item.Moid }} model={{ item.Model }}"
create: true
loop: "{{ outer_item.api_response }}"
loop_control:
label: "{{ item.Name }}"
when: outer_item.api_response is defined and outer_item.api_response