Azure / azure_preview_modules

Azure preview modules for Ansible
https://galaxy.ansible.com/azure/azure_preview_modules
43 stars 49 forks source link

azure_rm_aks 'NoneType' object does not support item assignment #338

Open T1loc opened 4 years ago

T1loc commented 4 years ago

Since I update to ansible 2.9 I'm not able anymore to use this task. (It was working well before) Ansible task:

 - azure_rm_aks:
      name: "{{ aks_cluster_name }}"
      dns_prefix: "{{ aks_cluster_subdomain }}"
      enable_rbac: yes
      kubernetes_version: "{{ aks_kubernetes_version }}"
      resource_group: "{{ azure_resource_group_name }}"
      linux_profile:
        admin_username: "{{ aks_admin_user }}"
        ssh_key: "{{ aks_admin_ssh_key }}"
      agent_pool_profiles:
        - name: default
          count: "{{ aks_cluster_default_vm_count }}"
          vm_size: "{{ aks_cluster_default_vm_size }}"
      service_principal:
          client_id: "{{ lookup('ini', 'client_id section=' + aks_service_principal_name +' file=~/.azure/credentials') }}"
          client_secret: "{{ lookup('ini', 'secret section=' + aks_service_principal_name +' file=~/.azure/credentials') }}"
      tags:
        Environment: "{{ aks_cluster_environment_tag }}"

Stack trace :

The full traceback is:
Traceback (most recent call last):
  File "/Users/florian/.ansible/tmp/ansible-tmp-1576249857.2375429-149151740595734/AnsiballZ_azure_rm_aks.py", line 102, in <module>
    _ansiballz_main()
  File "/Users/florian/.ansible/tmp/ansible-tmp-1576249857.2375429-149151740595734/AnsiballZ_azure_rm_aks.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/Users/florian/.ansible/tmp/ansible-tmp-1576249857.2375429-149151740595734/AnsiballZ_azure_rm_aks.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.cloud.azure.azure_rm_aks', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/var/folders/4n/k586r4d94fs6g8f1b6jlfcr80000gn/T/ansible_azure_rm_aks_payload_ut2crep9/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 838, in <module>
  File "/var/folders/4n/k586r4d94fs6g8f1b6jlfcr80000gn/T/ansible_azure_rm_aks_payload_ut2crep9/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 834, in main
  File "/var/folders/4n/k586r4d94fs6g8f1b6jlfcr80000gn/T/ansible_azure_rm_aks_payload_ut2crep9/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 526, in __init__
  File "/var/folders/4n/k586r4d94fs6g8f1b6jlfcr80000gn/T/ansible_azure_rm_aks_payload_ut2crep9/ansible_azure_rm_aks_payload.zip/ansible/module_utils/azure_rm_common.py", line 348, in __init__
  File "/var/folders/4n/k586r4d94fs6g8f1b6jlfcr80000gn/T/ansible_azure_rm_aks_payload_ut2crep9/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 542, in exec_module
  File "/var/folders/4n/k586r4d94fs6g8f1b6jlfcr80000gn/T/ansible_azure_rm_aks_payload_ut2crep9/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 752, in get_aks
  File "/var/folders/4n/k586r4d94fs6g8f1b6jlfcr80000gn/T/ansible_azure_rm_aks_payload_ut2crep9/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 304, in create_aks_dict
  File "/var/folders/4n/k586r4d94fs6g8f1b6jlfcr80000gn/T/ansible_azure_rm_aks_payload_ut2crep9/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 330, in create_addon_dict
TypeError: 'NoneType' object does not support item assignment

pip freeze

pip freeze ansible[azure]                                                                                                                                                                                                   
adal==1.2.2
ansible==2.9.2
ansible-lint==4.2.0
applicationinsights==0.11.9
argcomplete==1.10.3
azure-cli-core==2.0.35
azure-cli-nspkg==3.0.2
azure-common==1.1.11
azure-graphrbac==0.40.0
azure-keyvault==1.0.0a1
azure-mgmt-authorization==0.51.1
azure-mgmt-automation==0.1.1
azure-mgmt-batch==5.0.1
azure-mgmt-cdn==3.0.0
azure-mgmt-compute==4.4.0
azure-mgmt-containerinstance==1.4.0
azure-mgmt-containerregistry==2.0.0
azure-mgmt-containerservice==4.4.0
azure-mgmt-cosmosdb==0.5.2
azure-mgmt-devtestlabs==3.0.0
azure-mgmt-dns==2.1.0
azure-mgmt-hdinsight==0.1.0
azure-mgmt-iothub==0.7.0
azure-mgmt-keyvault==1.1.0
azure-mgmt-loganalytics==0.2.0
azure-mgmt-marketplaceordering==0.1.0
azure-mgmt-monitor==0.5.2
azure-mgmt-network==2.3.0
azure-mgmt-nspkg==2.0.0
azure-mgmt-rdbms==1.4.1
azure-mgmt-redis==5.0.0
azure-mgmt-resource==2.1.0
azure-mgmt-servicebus==0.5.3
azure-mgmt-sql==0.10.0
azure-mgmt-storage==3.1.0
azure-mgmt-trafficmanager==0.50.0
azure-mgmt-web==0.41.0
azure-nspkg==2.0.0
azure-storage==0.35.1
bcrypt==3.1.7
cachetools==3.1.1
certifi==2019.11.28
cffi==1.13.2
chardet==3.0.4
colorama==0.4.3
cryptography==2.8
dictdiffer==0.8.0
docker==4.1.0
google-auth==1.8.1
humanfriendly==4.18
idna==2.8
isodate==0.6.0
Jinja2==2.10.3
jmespath==0.9.4
jsondiff==1.2.0
knack==0.3.3
kubernetes==10.0.1
MarkupSafe==1.1.1
msrest==0.6.1
msrestazure==0.5.0
oauthlib==3.1.0
openshift==0.10.1
packaging==19.2
paramiko==2.7.1
pg==0.1
Pillow==6.2.1
prettytable==0.7.2
psycopg2-binary==2.8.4
pyasn1==0.4.8
pyasn1-modules==0.2.7
pycparser==2.19
Pygments==2.5.2
PyJWT==1.7.1
PyNaCl==1.3.0
PyOpenGL==3.1.4
pyOpenSSL==19.1.0
pyparsing==2.4.5
python-dateutil==2.8.1
python-string-utils==0.6.0
PyYAML==5.2
requests==2.22.0
requests-oauthlib==1.3.0
rsa==4.0
ruamel.yaml==0.16.5
ruamel.yaml.clib==0.2.0
six==1.13.0
tabulate==0.8.2
urllib3==1.25.7
virtualenv==16.7.8
websocket-client==0.56.0
xmltodict==0.12.0
Fred-sun commented 4 years ago

@T1loc My execution on 2.9.2 was successful. Could you please share your parameter information and location? I'll try again. Or you can reinstall ansible and retry it. Thank you very much! --"sudo PIP install ansible[azure]== 2.9.2 -I"


TASK [for test] ************************************************************************************************
task path: /home/fred/task/azure_338/tasks.yml:22
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: fred
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1576463885.19-278245734078679 `" && echo ansible-tmp-1576463885.19-278245734078679="` echo $HOME/.ansible/tmp/ansible-tmp-1576463885.19-278245734078679 `" ) && sleep 0'
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/cloud/azure_rm_aks.py
<127.0.0.1> PUT /home/fred/.ansible/tmp/ansible-local-5626ikVeve/tmptmG0Y2 TO /home/fred/.ansible/tmp/ansible-tmp-1576463885.19-278245734078679/AnsiballZ_azure_rm_aks.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/fred/.ansible/tmp/ansible-tmp-1576463885.19-278245734078679/ /home/fred/.ansible/tmp/ansible-tmp-1576463885.19-278245734078679/AnsiballZ_azure_rm_aks.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/fred/.ansible/tmp/ansible-tmp-1576463885.19-278245734078679/AnsiballZ_azure_rm_aks.py && sleep 0'

<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/fred/.ansible/tmp/ansible-tmp-1576463885.19-278245734078679/ > /dev/null 2>&1 && sleep 0'
[WARNING]: Azure API profile latest does not define an entry for ContainerServiceClient

changed: [127.0.0.1] => {
    "aad_profile": {}, 
    "addon": {}, 
    "agent_pool_profiles": [
        {
            "count": 1, 
            "name": "default", 
            "os_disk_size_gb": 100, 
            "os_type": "Linux", 
            "storage_profile": "ManagedDisks", 
            "vm_size": "Standard_DS1_v2", 
            "vnet_subnet_id": null
        }
    ], 
    "changed": true, 
    "dns_prefix": "fredaks01", 
    "enable_rbac": true, 
    "fqdn": "fredaks01-2a51dbb0.hcp.eastus.azmk8s.io", 
    "id": xxxxxx/managedClusters/fredaks01", 
    "invocation": {
        "module_args": {
            "aad_profile": null, 
            "ad_user": null, 
            "addon": null, 
            "adfs_authority_url": null, 
            "agent_pool_profiles": [
                {
                    "count": 1, 
                    "dns_prefix": null, 
                    "name": "default", 
                    "os_disk_size_gb": null, 
                    "os_type": null, 
                    "ports": null, 
                    "storage_profiles": null, 
                    "vm_size": "Standard_DS1_v2", 
                    "vnet_subnet_id": null
                }
            ], 
            "api_profile": "latest", 
            "append_tags": true, 
            "auth_source": null, 
            "cert_validation_mode": null, 
            "client_id": null, 
            "cloud_environment": "AzureCloud", 
            "dns_prefix": "fredaks01", 
            "enable_rbac": true, 
            "kubernetes_version": "1.14.8", 
            "linux_profile": {
                "admin_username": "azureuser", 
                "ssh_key": "xxxxxx"
            }, 
            "location": null, 
            "name": "fredaks01", 
            "network_profile": null, 
            "password": null, 
            "profile": null, 
            "resource_group": "v-xisuRG02", 
            "secret": null, 
            "service_principal": {
                "client_id": "ae12946a-f4de-4609-a5d1-68c36604f3b0", 
                "client_secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
            }, 
            "state": "present", 
            "subscription_id": null, 
            "tags": {
                "Environment": "test"
            }, 
            "tenant": null
        }
    }, 
    "kube_config": "apiVersion: v1\nclusters:\n- cluster:\n    xxxx, 
    "kubernetes_version": "1.14.8", 
    "linux_profile": {
        "admin_username": "azureuser", 
        "ssh_key": "xxxxxxxx"
    }, 
    "location": "eastus", 
    "name": "fredaks01", 
    "network_profile": {
        "dns_service_ip": "10.0.0.10", 
        "docker_bridge_cidr": "172.17.0.1/16", 
        "network_plugin": "kubenet", 
        "network_policy": null, 
        "pod_cidr": "10.244.0.0/16", 
        "service_cidr": "10.0.0.0/16"
    }, 
    "node_resource_group": "MC_v-xisuRG02_fredaks01_eastus", 
    "provisioning_state": "Succeeded", 
    "service_principal_profile": {
        "client_id": "ae12946a-f4de-4609-a5d1-68c36604f3b0"
    }, 
    "tags": {
        "Environment": "test"
    }, 
    "type": "Microsoft.ContainerService/ManagedClusters"
}
Fred-sun commented 4 years ago

kindly ping

T1loc commented 4 years ago

Sorry for the delay,

I use the westeurope location. And : p task.args give me :

agent_pool_profiles': [{'count': 5,
                          'name': 'default',
                          'vm_size': 'Standard_D2s_v3'}],
 'dns_prefix': 'mySubDomain',
 'enable_rbac': True,
 'kubernetes_version': '1.14.8',
 'linux_profile': {'admin_username': 'myAdmin',
                   'ssh_key': 'ssh-rsa '
                              'xxxxx'},
 'location': 'westeurope',
 'name': 'myAksName',
 'profile': 'myAzureFileSection',
 'resource_group': 'Staging',
 'service_principal': {'client_id': 'xxxx',
                       'client_secret': 'xxxx'},
 'tags': {'Environment': 'Staging'}}

Is it not something related to the addon key ? I do not set this key on my task

Fred-sun commented 4 years ago

@T1loc Thanks for your share! I will try agin!

Fred-sun commented 4 years ago

@T1loc Thank you very much for your interest in Ansible. This repo is no longer maintained in this repository and has been migrated to https://github.com/ansible-collections/azure Please re-submit this Issue in the above repository and closed this. Thank you very much!