Azure Dynamic Inventory Issue

Hi all,

I would like to get some help.

I have configure the following sync configuration.

  - key: tags.Environment
    separator: ""
  - key: powerstate
    separator: ""
  - key: image.offer
    separator: ""
    - name
    csp: "'azure'"

I got 2 issue that I need help with.

  1. Azure inventory doesn’t not capture virtual machine in stopped state.
  2. Disable host before syncing are override when a new sync trigger. How to prevent the overwrite. I did not tick the “Overwrite”. This behaviour doesn’t happen with AWS plugin. I assume its a Azure RM plugin issue.

Thanks for any help

Good morning, I use this for Azure:
Enabled Variable: provisioning_state
Enabled Value: succeeded
This enables also deallocated machines, as long as they have been imaged.

I do not manually disable or enable hosts. I think the whole idea of this variable is to have this detected automatically.
Instead I add a connection detection in front of every role together with end_host if not reachable for those.

Something like

- name: Check connection
  register: _ping_result
- name: Remove unwanted hosts from play_hosts
  ansible.builtin.meta: end_host
  when: _ping_result.unreachable is defined

I see thanks.

Do this consider a failed job template?

If you add an ignore_errors: true it would continue.

This is a philosophical question :smiley:
Some say: let jobs fail!
Some say: Do error handling!

I prefer error handling…

In this case , the end_host only for host that are not reachable right.

Other host that have no issue , those will still continue?

Yes, this is correct.

It will gracefully end the playbook for those hosts, not produce an error.

I just try adding provisoning_state.

Still unable to retrieve stopped(deallocated) virtual machine.

Any idea?

OK nevermind.

Found out the plugin has a
default_host_filters Default: ["powerstate != \"running\"", "provisioning_state != \"succeeded\""]

That why stopped VM are not showing.

I just need to remove the powerstate

Sorry, yes.
I clear all default host filters as well:

# filters
default_host_filters: []

Then add your own stuff here.