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

Not able to add backend server to existing SLB #286

Open
wrogrammer opened this issue Oct 5, 2020 · 0 comments
Open

Not able to add backend server to existing SLB #286

wrogrammer opened this issue Oct 5, 2020 · 0 comments

Comments

@wrogrammer
Copy link

wrogrammer commented Oct 5, 2020

Description:

We are trying to add the new ECS instance to the existing SLB with Ansible.

  1. The same playbook for the Hong Kong region is working as well.
  2. The same playbook for the Tokyo region is not working.
  3. As per documentation the environment variables are not respecting by ali_slb_server module:

https://www.diewufeiyang.com/ansible/en/modules/ali_slb_server_module.html

ALICLOUD_REGION or ALICLOUD_REGION_ID can be typically be used to specify the ALICLOUD region, when required, but this can also be configured in the footmark config file

The issue:

The specified LoadBalancerId does not exist.

The output:

raise exception\naliyunsdkcore.acs_exception.exceptions.ServerException: HTTP Status: 404 Error:InvalidLoadBalancerId.NotFound The specified LoadBalancerId does not exist. RequestID: FF49FF87-09FA-41EE-8444-154C53E6E619\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1

The code:

playbooks/slb_update.yml

- name: Add ECS instances to SLB
  hosts: localhost
  vars:
    alicloud_access_key: '{{ ALICLOUD_ACCESS_KEY }}'
    alicloud_secret_key: '{{ ALICLOUD_SECRET_KEY }}'
    alicloud_region: 'ap-northeast-1'
  tasks:
    - name: SLB update
      ali_slb_server:
        alicloud_access_key: '{{ alicloud_access_key }}'
        alicloud_secret_key: '{{ alicloud_secret_key }}'
        load_balancer_id: lb-foo
        backend_servers:
          - server_id: i-bar
            weight: 100

Similar issue:
#143

The solution:

I found the issue in the Python script:
https://github.com/alibaba/alibaba.alicloud/blob/aa6b0eaab7150abe294bca4e29e9239f0c843831/lib/ansible/modules/cloud/alicloud/ali_slb_server.py

    # handling region parameter which is required by common utils file to login but not required by this module
    module.params['alicloud_region'] = 'cn-hangzhou

The HK region is hardcoded.

Suggestion:

The region should be specified by the user and the HK should be used by default.

{"changed": false, "msg": "Unsupported parameters for (ali_slb_server) module: alicloud_region Supported parameters include: 

alicloud_access_key, alicloud_assume_role, alicloud_assume_role_arn, alicloud_assume_role_session_expiration, alicloud_assume_role_session_name, alicloud_secret_key, alicloud_security_token, backend_servers, ecs_role_name, load_balancer_id, profile, shared_credentials_file, state"}

alicloud_region should be possible to define in ali_slb_server section in Ansible playbook
or
the region environment should be respected.

Temporary solution:

Please go to the Ansible modules directory.

ansible-playbook --version
ansible-playbook 2.9.13
  config file = None
  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-playbook

cd /usr/local/lib/python3.6/site-packages/ansible/modules/cloud/alicloud

find the ali_slb_server.py file and go to the 386 line to change the region variable.

Regions IDs:
https://www.alibabacloud.com/help/doc-detail/40654.ht

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

1 participant