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

azure_rm_roledefinition fails when description is set (except for initial creation) #158

Closed
wrprice opened this issue Jun 12, 2020 · 0 comments · Fixed by #214
Closed

azure_rm_roledefinition fails when description is set (except for initial creation) #158

wrprice opened this issue Jun 12, 2020 · 0 comments · Fixed by #214

Comments

@wrprice
Copy link

wrprice commented Jun 12, 2020

SUMMARY

Setting the description property on the azure_rm_roledefinition module succeeds during initial creation, but fails on subsequent runs with a Python stacktrace during check_update without making any other changes.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure_rm_roledefinition

ANSIBLE VERSION
ansible 2.9.9
  config file = /home/myUserDir/ansible/ansible.cfg
  configured module search path = ['/home/myUserDir/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0]
CONFIGURATION
DEFAULT_HOST_LIST(/home/myUserDir/ansible/ansible.cfg) = ['/home/myUserDir/ansible/inventory']
DEFAULT_PRIVATE_KEY_FILE(/home/myUserDir/ansible/ansible.cfg) = /home/myUserDir/auth/ssh/local/id_rsa
INVENTORY_ENABLED(/home/myUserDir/ansible/ansible.cfg) = ['auto', 'yaml']
OS / ENVIRONMENT

Windows 10 Enterprise version 1909 build 18363.900
WSL 1.x running Ubuntu 18.04.4 LTS
Linux 4.4.0-18362-Microsoft #836-Microsoft Mon May 05 16:04:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux

STEPS TO REPRODUCE
  1. Update provided example play with a valid subscription ID, change auth_source as needed.
  2. Run example play, it should create a new custom role (1 changed)
  3. Run example play again, it will fail with a python stacktrace
- hosts: localhost
  gather_facts: no
  vars:
    subscription_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

  tasks:
    - azure_rm_roledefinition:
        auth_source: cli
        subscription_id: "{{ subscription_id | mandatory }}"
        name: Test Custom RBAC Role
        description: Can be set on create, but throws on subsequent runs
        scope: "/subscriptions/{{ subscription_id | mandatory }}"
        assignable_scopes:
          - "/subscriptions/{{ subscription_id | mandatory }}"
        state: present
        permissions:
          - actions:
              - "*/read"
EXPECTED RESULTS

On first run, expect play successful with ok=1 changed=1 failed=0
On second run, expect play successful with ok=1 changed=0 failed=0

ACTUAL RESULTS

Second run terminates with Python exception, ok=0 changed=0 failed=1

First run:

PLAY [localhost] ***************************************************************************************************************************

TASK [azure_rm_roledefinition] *************************************************************************************************************
[WARNING]: Azure API profile latest does not define an entry for AuthorizationManagementClient
changed: [localhost]

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

Second run:

PLAY [localhost] ***************************************************************************************************************************

TASK [azure_rm_roledefinition] *************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'properties'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/myUserDir/.ansible/tmp/ansible-tmp-1591976595.156447-7552-47076256971497/AnsiballZ_azure_rm_roledefinition.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/myUserDir/.ansible/tmp/ansible-tmp-1591976595.156447-7552-47076256971497/AnsiballZ_azure_rm_roledefinition.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/myUserDir/.ansible/tmp/ansible-tmp-1591976595.156447-7552-47076256971497/AnsiballZ_azure_rm_roledefinition.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.cloud.azure.azure_rm_roledefinition', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_azure_rm_roledefinition_payload_q4mkw6wi/ansible_azure_rm_roledefinition_payload.zip/ansible/modules/cloud/azure/azure_rm_roledefinition.py\", line 402, in <module>\n  File \"/tmp/ansible_azure_rm_roledefinition_payload_q4mkw6wi/ansible_azure_rm_roledefinition_payload.zip/ansible/modules/cloud/azure/azure_rm_roledefinition.py\", line 398, in main\n  File \"/tmp/ansible_azure_rm_roledefinition_payload_q4mkw6wi/ansible_azure_rm_roledefinition_payload.zip/ansible/modules/cloud/azure/azure_rm_roledefinition.py\", line 209, in __init__\n  File \"/tmp/ansible_azure_rm_roledefinition_payload_q4mkw6wi/ansible_azure_rm_roledefinition_payload.zip/ansible/module_utils/azure_rm_common.py\", line 348, in __init__\n  File \"/tmp/ansible_azure_rm_roledefinition_payload_q4mkw6wi/ansible_azure_rm_roledefinition_payload.zip/ansible/modules/cloud/azure/azure_rm_roledefinition.py\", line 248, in exec_module\n  File \"/tmp/ansible_azure_rm_roledefinition_payload_q4mkw6wi/ansible_azure_rm_roledefinition_payload.zip/ansible/modules/cloud/azure/azure_rm_roledefinition.py\", line 287, in check_update\nKeyError: 'properties'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

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

Seems to be a problem referencing old_definition['properties'] on line 287. As a workaround, leaving the description property unset in the play bypasses this check.

GuopengLin added a commit to GuopengLin/azure that referenced this issue Aug 3, 2020
haiyuazhang pushed a commit that referenced this issue Aug 5, 2020
* fix issue #158 and add tests
Fred-sun pushed a commit to Fred-sun/ansible_collections_azure that referenced this issue Sep 3, 2020
… of a Storage Account. (ansible-collections#108)

* Add support for managing the 'Firewall and virtual networks' settings of
a Storage Account.

Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com>

Update azure_rm_publicipaddress

add test sample

codebase cleanup: update format (ansible-collections#131)

* Update format

refine azure devops pipeline (ansible-collections#138)

* refine azure devops pipeline

enable single module test (ansible-collections#144)

*  enable single module test

bug fixing in azure_rm_aks module(ansible-collections#170)

* bug fixing in azure_rm_aks module

For Test( 2.9 to 2.10) (ansible-collections#140)

* adding more testing dimensions

Add FileEndpoint to azure_rm_storageaccount_info (ansible-collections#102)

* Add FileEndpoint to azure_rm_storageaccount_info

Use hasattr instead of dir (ansible-collections#75)

Add ephemeral OS disk for azure_rm_virtualmachine (ansible-collections#124)

* Add ephemeral OS disk  support for azure_rm_virtualmachine

Add ephemeral OS disk for azure_rm_virtualmachinescaleset (ansible-collections#128)

* Add ephemeral OS disk support for azure_rm_virtualmachinescaleset

Change network_client api_version to match latest default api_version (ansible-collections#157)

* #Fixes 156
Change network_client api_version to match latest default api_version

* #Fixes 156
Update azure-mgmt-network to 10.2.0
Update 'latest' version listing and default version for Network Client to 2018-08-01

Add ability to remove all Subnet Service Endpoints when supplying an empty list. (ansible-collections#148)

New azure_rm_privatednszone module with tests (ansible-collections#122)

* New azure_rm_privatednszone module with tests

Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com>
Co-authored-by: Fred-sun <xiuxi.sun@qq.com>

Add new azure active directory related modules (ansible-collections#179)

* add ad related modules

* release v0.2.0 preparation and minor ad module bug fixing

fixing sanity testing errors in ad related modules (ansible-collections#182)

* disable ad relate module test
* fixing sanity testing errors in ad related modules

Fixing issues in azure_rm_deployment_info.py  (ansible-collections#180)

- Fixing getting the template_link when it does not exist.
- Feature: Return the correlation_id

Co-authored-by: Steve Kieu <steve.kieu@xvt.com.au>

azure_rm_virtualmachine: Protect against no diskSizeGB (ansible-collections#185)

Disks `diskSizeGB` is not reported if the Virtual Machine is
deallocated.  Trying to fetch it is causing a `KeyError`. This guards
against that KeyError and then nulls out the key so it isn't set
incorrectly in the update call.

Fix wrong module deprecate statement format (ansible-collections#176)

* fix wrong module deprecate statement format

update doc

add batch upload feature in azure_rm_storageblob (ansible-collections#203)

Co-authored-by: haiyuazhang <haiyuan.zhang1982@gmaile.com>

fixing status code issue in azure_rm_deployment (ansible-collections#204)

Co-authored-by: haiyuazhang <haiyuan.zhang1982@gmaile.com>

fixing update check bug in azure_rm_adserviceprincipal (ansible-collections#205)

Bump version to v0.3.0

update doc

change service_url to service_uri (ansible-collections#212)

Storageaccount tlsversion (ansible-collections#207)

* add support for minimum_tls_version

fix(vm): fix boot diagnistics option "no" caused an error (ansible-collections#200)

Fix the issue ansible-collections#158 (ansible-collections#214)

* fix issue ansible-collections#158 and add tests

azure_rm_appgateway.py: Support Version 2 SKUs (ansible-collections#198)

fix sanity test issues (ansible-collections#223)

Bump version to v0.4.0

lift v0.4.0 to v1.0.0

update new pr-pipeline (ansible-collections#229)

Add execution environment metadata (ansible-collections#220)

Storage account allow blob public access parameter (ansible-collections#219)

* Storage account allow blob public access parameter

* Change name of test to match correct attribute.

Update azure_rm_virtualmachine boot_diagnostics resource group config… (ansible-collections#208)

* Update azure_rm_virtualmachine boot_diagnostics resource group configuration

Update azure_rm_storageaccount.py file (ansible-collections#233)

* Uneatable parameters do not need to set default values

fix the problem of disk lun self-increment (ansible-collections#237)

Fixing rule_type reference (ansible-collections#99)

Reference to ev instead of item is preventing the expected rule_type values from functioning

Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com>

add load_balancer_sku option for aks (ansible-collections#199)

* added load_balancer_sku option for aks

Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com>

Improve OS detection when VM has no osProfile (ansible-collections#197)

We have VM without OS profile (checked on https://resources.azure.com/) and they appear as "unknown" os :-/

This appear to be a known issue: https://support.microsoft.com/en-ph/help/4018140/computer-names-of-specialized-virtual-machines-are-missing-or-blank-in

Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com>
Co-authored-by: haiyuan_zhang <haiyuan.zhang1982@gmail.com>

Add IPv6 address for azure_rm_subnet (ansible-collections#240)

* Add IPv6 address for azure_rm_subnet

Get address_prefixes info from virtualnetwork (ansible-collections#239)

* Add new parameter for get subnet IPv6 info

Support azure cli credentials with multiple `subscription_id`s (ansible-collections#195)

* feat: Support azure cli credentials with multiple `subscription_id`s

If the `subscription_id` is specified as module parameter or in the
environment then try to find that subscription in either the MSI (existing) or
CLI credentials (new). This patch brings those two scenarios in line.

* docs: Improve documentation on auth_source

* refactor: Move defaults up to class

Just trying to make the `__init__` fn a bit slimmer and easier to
reason about.

* refactor: Use python kwargs instead of passing dict

This is an isomorphic change, just using python syntax to accomplish
the exact same thing.

* refactor: Use ansible builtin `env_fallback` for `auth_source`

Ansible modules have a pattern for looking up a module parameter in
the environment with precedence of explicit param -> env -> default.
Use this pattern to simplify our code here.

This shouldn't change any behavior of `auth_source`, just using
standard ansible patterns to accomplish it.

* style: Split long line

No semantic change, just wrapping a long line to be a bit more
readable.

* refactor: helper fun _get_env

Somewhat frequently there is a lookup in the environment for the key that
matches a module parameter. This simple helper just encapsulates that
to make it a bit easier elsewhere-- lookup the same key in params,
credentials, env

* fix: typo in log message

Co-authored-by: Justin Ossevoort <justin.ossevoort@tesorion.nl>

Add 10.3 version for azure_rm_mariadbserver module (ansible-collections#244)

* add new version for azure_rm_mariadbserver

Update azure_rm_storageaccount yaml (ansible-collections#226)

* update azure_rm_storageaccount test
* update pipeline file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant