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

add group_by_os_family in azure dynamic inventory #40702

Merged
merged 6 commits into from
Aug 9, 2018

Conversation

EtienneDeneuve
Copy link
Contributor

SUMMARY

Add a way to group by os family.

I need that for set correct winrm/ssh connection in group_vars

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

azure_rm.py
azure_rm.ini

ANSIBLE VERSION
ansible 2.5.3
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/neocaseadmin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]
ADDITIONAL INFORMATION

@ansibot
Copy link
Contributor

ansibot commented May 25, 2018

The test ansible-test sanity --test pylint [explain] failed with 1 error:

contrib/inventory/azure_rm.py:818:0: syntax-error unindent does not match any outer indentation level (<string>, line 818)

The test ansible-test sanity --test compile --python 2.6 [explain] failed with 1 error:

contrib/inventory/azure_rm.py:818:35: SyntaxError: if self.group_by_os_family:

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

contrib/inventory/azure_rm.py:818:35: SyntaxError: if self.group_by_os_family:

The test ansible-test sanity --test compile --python 3.5 [explain] failed with 1 error:

contrib/inventory/azure_rm.py:818:35: SyntaxError: if self.group_by_os_family:

The test ansible-test sanity --test compile --python 3.6 [explain] failed with 1 error:

contrib/inventory/azure_rm.py:818:35: SyntaxError: if self.group_by_os_family:

The test ansible-test sanity --test compile --python 3.7 [explain] failed with 1 error:

contrib/inventory/azure_rm.py:818:35: SyntaxError: if self.group_by_os_family:

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

contrib/inventory/azure_rm.py:818:8: E901 IndentationError: unindent does not match any outer indentation level

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented May 25, 2018

@ansibot ansibot added affects_2.6 This issue/PR affects Ansible v2.6 azure c:inventory/contrib_script ci_verified Changes made in this PR are causing tests to fail. cloud inventory Inventory category needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. labels May 25, 2018
@ansibot ansibot removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels May 25, 2018
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label May 25, 2018
@EtienneDeneuve
Copy link
Contributor Author

Where is the doc of azure_rm inventory ? I need to update it to add what provide my few additions to initial script.

@yuwzho
Copy link
Contributor

yuwzho commented May 28, 2018

@@ -808,10 +810,16 @@ def _add_host(self, vars):

host_name = self._to_safe(vars['name'])
resource_group = self._to_safe(vars['resource_group'])
operating_system_type = self._to_safe(vars['os_disk']['operating_system_type'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change looks good. pls update doc as @yuwzho mentioned.

@ansibot ansibot added docs This issue/PR relates to or includes documentation. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 28, 2018
@EtienneDeneuve
Copy link
Contributor Author

@yungezz

The doc is updated.

I think there's maybe an little enhancement, for me it's better to ensure the operating_system_type is in lower case, no? I'm not a python guru but I think we can change in 2 places:

host_vars['os_disk'] = dict(
                name=machine.storage_profile.os_disk.name,
                operating_system_type=machine.storage_profile.os_disk.os_type.value
            )

by

host_vars['os_disk'] = dict(
                name=machine.storage_profile.os_disk.name,
                operating_system_type=machine.storage_profile.os_disk.os_type.value.tolower()
            )

Or in the group :

 def _add_host(self, vars):
        host_name = self._to_safe(vars['name'])
        resource_group = self._to_safe(vars['resource_group'])
        operating_system_type = self._to_safe(vars['os_disk']['operating_system_type'])
        security_group = None

by

 def _add_host(self, vars):
        host_name = self._to_safe(vars['name'])
        resource_group = self._to_safe(vars['resource_group'])
        operating_system_type = self._to_safe(vars['os_disk']['operating_system_type'].tolower())
        security_group = None

I don't know which is the best/correct way to handle that. Azure send the data with Windows or Linux, and so in group_vars, we need to create Windows.yml or Linux.yml instead of lower case.
For me, the second option is better as we don't alter the Azure output in the inventory but create the dynamic group in lower case. I wait for your advice and update the PR with the correct way.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jun 5, 2018
@yungezz
Copy link
Contributor

yungezz commented Jun 13, 2018

@EtienneDeneuve each way is ok for me. I personal prefer to lower case in _add_host.

@EtienneDeneuve
Copy link
Contributor Author

EtienneDeneuve commented Jun 13, 2018 via email

@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jun 14, 2018
@@ -808,10 +810,16 @@ def _add_host(self, vars):

host_name = self._to_safe(vars['name'])
resource_group = self._to_safe(vars['resource_group'])
operating_system_type = self._to_safe(vars['os_disk']['operating_system_type'].tolower())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lower()

@yungezz
Copy link
Contributor

yungezz commented Jun 19, 2018

@jborean93 Hi Jordan, this PR adds a new option group_by_os_family to azure inventory. pls help to review when available. I've tested it locally.

@@ -402,6 +404,12 @@ Here are some examples using the inventory script:
# Execute /bin/uname on all instances in the Testing resource group
$ ansible -i azure_rm.py Testing -m shell -a "/bin/uname -a"

# Execute win_ping on all Windows instances
$ ansible -i azure_rm.py Windows -m win_ping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update sample to use lower case os name

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jun 27, 2018
@yungezz
Copy link
Contributor

yungezz commented Jul 10, 2018

@EtienneDeneuve will you update the PR per comments? I can help after you give me repo permission.

@EtienneDeneuve
Copy link
Contributor Author

Oh too bad I didn’t saw your comment until yet!

I’ll fix as mentioned today!

@ansibot
Copy link
Contributor

ansibot commented Aug 3, 2018

@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Aug 3, 2018
update to match lower case
@EtienneDeneuve
Copy link
Contributor Author

Normally fixed the 'tolower()' by 'lower()' and change in doc

@yungezz
Copy link
Contributor

yungezz commented Aug 9, 2018

shipit

$ ansible -i azure_rm.py windows -m win_ping

# Execute win_ping on all Windows instances
$ ansible -i azure_rm.py winux -m ping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: linux

@yungezz yungezz merged commit 379fb87 into ansible:devel Aug 9, 2018
alikins added a commit that referenced this pull request Aug 10, 2018
* devel: (30 commits)
  Prevent data being truncated over persistent connection socket (#43885)
  Fix eos_command integration test failures (#43922)
  Update iosxr cliconf plugin (#43837)
  win_domain modules: ensure Netlogon service is still running after promotion (#43703)
  openvswitch_db : Handle column value conversion and idempotency in no_key case (#43869)
  Fix typo
  Fix spelling of ansbile to ansible (#43898)
  added platform guides for NOS and VOSS (#43854)
  Fix download URL for yum integration test.
  New module for managing EMC VNX Block storage (#42945)
  Docker integration tests: factorize setup (#42306)
  VMware: datastore selection (#35812)
  Remove unnecessary features from cli_command (#43829)
  [doc] import_role: mention version from which behavior changed and fix some typos (#43843)
  Add source interface and use-vrf features (#43418)
  Fix unreferenced msg from vmware_host (#43872)
  set supports_generate_diff to False vyos (#43873)
  add group_by_os_family in azure dynamic inventory (#40702)
  ansible-test: Create public key creating Windows targets (#43760)
  azure_rm_loadbalancer_facts.py: list() takes at least 2 arguments fix (#29046) (#29050)
  ...
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.6 This issue/PR affects Ansible v2.6 azure c:inventory/contrib_script cloud docs This issue/PR relates to or includes documentation. inventory Inventory category new_contributor This PR is the first contribution by a new community member. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants