Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically match network_name to network_id for the deployement of new VM´s on VMWare #1104

Closed
SimonLorentz opened this issue Dec 17, 2020 · 2 comments · Fixed by #1136
Closed

Comments

@SimonLorentz
Copy link

SimonLorentz commented Dec 17, 2020

SUMMARY

If I deploy a new Host over Foreman on my VMWare Cluster, with the host FAM, I need to manually check the correct network_id for my network or otherwise Foreman will always show a wrong network in the VM´s Interface tab.

Should be nearly the same like: #1041

ISSUE TYPE
  • Feature Idea

Automatically lookup the correct network_id for a network_name. I coul use as workaround the Ansible URI Module to do this, but, this is probably not the best solution, it would be better to implement it into the host FAM.

Here is an example of my workaround:

- name: Get network ids
  uri:
    url: "{{ foreman_server_url }}/api/compute_resources/{{ compute_ressource_id }}/available_networks"
    user: "{{ foreman_admin_user }}"
    password: "{{ foreman_admin_password }}"
    method: GET
    return_content: true
    force_basic_auth: true
    validate_certs: "{{ validate_foreman_certs }}"
  register: available_networks
  no_log: true

- set_fact:
    vsphere_network_id1: "{{ available_networks | json_query(query) | first }}"
  vars:
    query: "json.results[?name=='{{ foreman_host_vm.networkinterfaces[0].name }}'].id"
@evgeni
Copy link
Member

evgeni commented Dec 17, 2020

I wanted to say it is a duplicate #1041, but that is about the compute profile, while here you're talking about hosts. But yeah, once implemented it can be applied in both modules

@fgoebel
Copy link

fgoebel commented Jan 7, 2021

Thank you very much for providing that example snipped. I would have get this to work, but it devinetly would have taken more time!

@evgeni evgeni self-assigned this Feb 2, 2021
evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue Feb 3, 2021
evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue Feb 15, 2021
evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue Feb 15, 2021
evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue Feb 22, 2021
evgeni added a commit that referenced this issue Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants