From 7884ee4f353500e1242479d7170538f96d252bb2 Mon Sep 17 00:00:00 2001 From: lixue <1120722567@qq.com> Date: Fri, 24 Apr 2020 18:43:31 +0800 Subject: [PATCH] build collection --- .gitignore | 111 --- .travis.yml | 38 - CHANGELOG.md | 288 -------- COPYING | 675 ++++++++++++++++++ LICENSE | 190 ----- MANIFEST.in | 6 - README.md | 139 ++-- lib/__init__.py => __init__.py | 0 contrib/README.md | 26 - .../dev_guide/developing_module_utilities.rst | 54 -- docs/docsite/rst/guide_alicloud.rst | 126 ---- galaxy.yml | 17 + lib/CHANGELOG.md | 42 -- lib/MANIFEST.in | 8 - lib/ansible/__init__.py | 28 - lib/ansible/galaxy/deploy/.travis.yml | 29 - lib/ansible/galaxy/deploy/README.md | 115 --- lib/ansible/galaxy/deploy/defaults/main.yml | 59 -- lib/ansible/galaxy/deploy/meta/main.yml | 20 - lib/ansible/galaxy/deploy/tasks/create.yml | 78 -- lib/ansible/galaxy/deploy/tasks/deploy.yml | 58 -- lib/ansible/galaxy/deploy/tasks/main.yml | 7 - lib/ansible/galaxy/deploy/tests/test.yml | 5 - lib/ansible/galaxy/market/.travis.yml | 29 - lib/ansible/galaxy/market/README.md | 100 --- lib/ansible/galaxy/market/defaults/main.yml | 64 -- lib/ansible/galaxy/market/meta/main.yml | 19 - lib/ansible/galaxy/market/tasks/create.yml | 52 -- lib/ansible/galaxy/market/tasks/main.yml | 6 - lib/ansible/galaxy/market/tasks/security.yml | 16 - lib/ansible/galaxy/market/tasks/vpc.yml | 14 - lib/ansible/galaxy/market/tasks/vswitch.yml | 18 - lib/ansible/galaxy/market/tests/inventory | 2 - lib/ansible/galaxy/market/tests/test.yml | 5 - lib/ansible/galaxy/tags/.travis.yml | 29 - lib/ansible/galaxy/tags/README.md | 68 -- lib/ansible/galaxy/tags/defaults/main.yml | 26 - lib/ansible/galaxy/tags/handlers/main.yml | 2 - lib/ansible/galaxy/tags/meta/main.yml | 21 - lib/ansible/galaxy/tags/tasks/main.yml | 75 -- lib/ansible/galaxy/tags/tests/inventory | 2 - lib/ansible/galaxy/tags/tests/test.yml | 5 - lib/ansible/module_utils/__init__.py | 20 - lib/ansible/modules/cloud/__init__.py | 2 - .../modules/cloud/alicloud/_ali_disk_facts.py | 255 ------- .../modules/cloud/alicloud/_ali_eip_facts.py | 231 ------ .../modules/cloud/alicloud/_ali_eni_facts.py | 232 ------ .../cloud/alicloud/_ali_image_facts.py | 283 -------- .../cloud/alicloud/_ali_instance_facts.py | 428 ----------- .../cloud/alicloud/_ali_oss_bucket_facts.py | 170 ----- .../cloud/alicloud/_ali_oss_object_facts.py | 185 ----- .../cloud/alicloud/_ali_rds_account_facts.py | 196 ----- .../cloud/alicloud/_ali_rds_instance_facts.py | 302 -------- .../cloud/alicloud/_ali_route_entry_facts.py | 209 ------ .../alicloud/_ali_security_group_facts.py | 255 ------- .../cloud/alicloud/_ali_slb_lb_facts.py | 317 -------- .../cloud/alicloud/_ali_slb_listener_facts.py | 176 ----- .../cloud/alicloud/_ali_slb_server_facts.py | 193 ----- .../cloud/alicloud/_ali_slb_vsg_facts.py | 196 ----- .../modules/cloud/alicloud/_ali_vpc_facts.py | 229 ------ .../cloud/alicloud/_ali_vswitch_facts.py | 237 ------ .../cloud/alicloud/_alicloud_bucket.py | 215 ------ .../cloud/alicloud/_alicloud_bucket_object.py | 383 ---------- .../modules/cloud/alicloud/_alicloud_disk.py | 432 ----------- .../cloud/alicloud/_alicloud_disk_facts.py | 258 ------- .../modules/cloud/alicloud/_alicloud_eip.py | 265 ------- .../alicloud/_alicloud_ess_configuration.py | 353 --------- .../cloud/alicloud/_alicloud_ess_group.py | 328 --------- .../cloud/alicloud/_alicloud_ess_instance.py | 187 ----- .../cloud/alicloud/_alicloud_ess_rule.py | 260 ------- .../cloud/alicloud/_alicloud_ess_task.py | 326 --------- .../cloud/alicloud/_alicloud_instance.py | 589 --------------- .../alicloud/_alicloud_instance_facts.py | 248 ------- .../alicloud/_alicloud_instance_type_facts.py | 226 ------ .../cloud/alicloud/_alicloud_rds_account.py | 379 ---------- .../cloud/alicloud/_alicloud_route_entry.py | 324 --------- .../alicloud/_alicloud_security_group.py | 618 ---------------- .../cloud/alicloud/_alicloud_slb_lb.py | 333 --------- .../cloud/alicloud/_alicloud_slb_listener.py | 478 ------------- .../cloud/alicloud/_alicloud_slb_server.py | 440 ------------ .../cloud/alicloud/_alicloud_slb_vsg.py | 385 ---------- .../modules/cloud/alicloud/_alicloud_vpc.py | 277 ------- .../cloud/alicloud/_alicloud_vswitch.py | 299 -------- lib/ansible/utils/__init__.py | 20 - lib/setup.py | 52 -- plugins/README.md | 31 + {lib/ansible/modules => plugins}/__init__.py | 0 .../doc_fragments}/__init__.py | 0 .../doc_fragments}/alicloud.py | 0 .../examples}/alicloud-ecs-vpc/LICENSE.md | 0 .../examples}/alicloud-ecs-vpc/README.md | 0 .../examples}/alicloud-ecs-vpc/alicloud.yml | 0 .../examples}/alicloud-ecs-vpc/destroy.yml | 0 .../examples}/alicloud-ecs-vpc/group_vars/all | 0 .../roles/disk/tasks/main.yml | 0 .../roles/instance/tasks/main.yml | 0 .../roles/security_group/tasks/main.yml | 0 .../alicloud-ecs-vpc/roles/vpc/tasks/main.yml | 0 .../roles/vswitch/tasks/main.yml | 0 .../examples}/alicloud-ecs-vpc/test.yml | 0 .../examples}/market/LICENSE.md | 0 .../examples}/market/README.md | 0 .../examples}/market/create.yml | 0 .../examples}/market/destroy.yml | 0 .../examples}/market/group_vars/all | 0 .../roles/security_group/tasks/main.yml | 0 .../examples}/market/roles/vpc/tasks/main.yml | 0 .../market/roles/vswitch/tasks/main.yml | 0 .../examples}/petstore/LICENSE.md | 0 .../examples}/petstore/README.md | 0 .../examples}/petstore/alicloud.ini | 0 .../examples/petstore}/alicloud.py | 0 .../examples}/petstore/create.yml | 0 .../examples}/petstore/delete.yml | 0 .../examples}/petstore/deploy.yml | 0 .../examples}/petstore/group_vars/all | 0 .../petstore/roles/instance/tasks/main.yml | 0 .../roles/security_group/tasks/main.yml | 0 .../petstore/roles/vpc/tasks/main.yml | 0 .../petstore/roles/vswitch/tasks/main.yml | 0 .../examples}/tags/LICENSE.md | 0 {examples => plugins/examples}/tags/README.md | 0 .../examples}/tags/group_vars/all | 0 {examples => plugins/examples}/tags/tags.yml | 0 .../inventory}/__init__.py | 0 .../inventory/alicloud.yml | 2 +- .../inventory/alicloud_ecs.py | 16 +- plugins/inventory/script/__init__.py | 0 .../inventory/script}/alicloud.ini | 0 .../inventory/script}/alicloud.py | 0 plugins/module_utils/__init__.py | 0 .../module_utils/alicloud_ecs.py | 0 .../module_utils/alicloud_oss.py | 0 plugins/modules/__init__.py | 0 .../alicloud => plugins/modules}/ali_disk.py | 4 +- .../modules}/ali_disk_info.py | 4 +- .../modules}/ali_dns_domain.py | 4 +- .../modules}/ali_dns_domain_info.py | 4 +- .../modules}/ali_dns_group.py | 4 +- .../modules}/ali_dns_group_info.py | 4 +- .../modules}/ali_ecs_tag.py | 4 +- .../alicloud => plugins/modules}/ali_eip.py | 4 +- .../modules}/ali_eip_info.py | 4 +- .../alicloud => plugins/modules}/ali_eni.py | 4 +- .../modules}/ali_eni_info.py | 4 +- .../modules}/ali_ess_configuration.py | 4 +- .../modules}/ali_ess_group.py | 4 +- .../modules}/ali_ess_instance.py | 4 +- .../modules}/ali_ess_rule.py | 4 +- .../modules}/ali_ess_task.py | 4 +- .../alicloud => plugins/modules}/ali_image.py | 4 +- .../modules}/ali_image_info.py | 4 +- .../modules}/ali_instance.py | 4 +- .../modules}/ali_instance_info.py | 4 +- .../modules}/ali_instance_type_facts.py | 4 +- .../modules}/ali_market_product_info.py | 4 +- .../modules}/ali_oos_execution.py | 4 +- .../modules}/ali_oos_execution_info.py | 4 +- .../modules}/ali_oos_template.py | 4 +- .../modules}/ali_oos_template_info.py | 4 +- .../modules}/ali_oss_bucket.py | 2 +- .../modules}/ali_oss_bucket_info.py | 2 +- .../modules}/ali_oss_object.py | 2 +- .../modules}/ali_oss_object_info.py | 2 +- .../modules}/ali_ram_access_key.py | 4 +- .../modules}/ali_ram_access_key_info.py | 4 +- .../modules}/ali_ram_group.py | 4 +- .../modules}/ali_ram_group_info.py | 4 +- .../modules}/ali_ram_login_profile.py | 4 +- .../modules}/ali_ram_login_profile_info.py | 4 +- .../modules}/ali_ram_policy.py | 4 +- .../modules}/ali_ram_policy_info.py | 4 +- .../modules}/ali_ram_role.py | 4 +- .../modules}/ali_ram_role_info.py | 4 +- .../modules}/ali_ram_user.py | 4 +- .../modules}/ali_ram_user_info.py | 4 +- .../modules}/ali_rds_account.py | 4 +- .../modules}/ali_rds_account_info.py | 4 +- .../modules}/ali_rds_backup.py | 4 +- .../modules}/ali_rds_backup_info.py | 4 +- .../modules}/ali_rds_database.py | 4 +- .../modules}/ali_rds_database_info.py | 4 +- .../modules}/ali_rds_instance.py | 4 +- .../modules}/ali_rds_instance_info.py | 4 +- .../modules}/ali_ros_stack.py | 4 +- .../modules}/ali_ros_stack_info.py | 4 +- .../modules}/ali_route_entry.py | 4 +- .../modules}/ali_route_entry_info.py | 4 +- .../modules}/ali_security_group.py | 4 +- .../modules}/ali_security_group_info.py | 4 +- .../modules}/ali_slb_lb.py | 4 +- .../modules}/ali_slb_lb_info.py | 4 +- .../modules}/ali_slb_listener.py | 4 +- .../modules}/ali_slb_listener_info.py | 4 +- .../modules}/ali_slb_server.py | 4 +- .../modules}/ali_slb_server_info.py | 4 +- .../modules}/ali_slb_tag.py | 4 +- .../modules}/ali_slb_vsg.py | 4 +- .../modules}/ali_slb_vsg_info.py | 4 +- .../alicloud => plugins/modules}/ali_vpc.py | 5 +- .../modules}/ali_vpc_info.py | 4 +- .../modules}/ali_vpc_tag.py | 4 +- .../modules}/ali_vswitch.py | 4 +- .../modules}/ali_vswitch_info.py | 4 +- plugins/tests/__init__.py | 0 .../tests}/ali_disk_info_test.yml | 2 + .../tests}/ali_dns_domain_info_test.yml | 2 + .../tests}/ali_dns_domain_test.yml | 2 + .../tests}/ali_dns_group_info_test.yml | 2 + .../tests}/ali_dns_group_test.yml | 2 + {tests => plugins/tests}/ali_ecs_tag_test.yml | 2 + .../tests}/ali_eip_info_test.yml | 2 + {tests => plugins/tests}/ali_eip_test.yml | 2 + .../tests}/ali_eni_info_test.yml | 2 + {tests => plugins/tests}/ali_eni_test.yml | 2 + .../tests}/ali_instance_info_test.yml | 2 + .../tests}/ali_instance_prepaid_test.yml | 2 + .../tests}/ali_instance_test.yml | 2 + .../tests}/ali_market_product_test.yml | 2 + .../tests}/ali_oos_execution_info_test.yml | 2 + .../tests}/ali_oos_execution_test.yml | 2 + .../tests}/ali_oos_template_info_test.yml | 0 .../tests}/ali_oos_template_test.yml | 0 .../tests}/ali_ram_access_key_info_test.yml | 0 .../tests}/ali_ram_access_key_test.yml | 0 .../tests}/ali_ram_group_info_test.yml | 0 .../tests}/ali_ram_group_test.yml | 0 .../ali_ram_login_profile_info_test.yml | 0 .../tests}/ali_ram_login_profile_test.yml | 0 .../tests}/ali_ram_policy_info_test.yml | 0 .../tests}/ali_ram_policy_test.yml | 0 .../tests}/ali_ram_profile_info_test.yml | 0 .../tests}/ali_ram_profile_test.yml | 0 .../tests}/ali_ram_role_info_test.yml | 0 .../tests}/ali_ram_role_test.yml | 0 .../tests}/ali_ram_user_info_test.yml | 0 .../tests}/ali_ram_user_test.yml | 0 .../tests}/ali_rds_account_info_test.yml | 2 + .../tests}/ali_rds_account_test.yml | 2 + .../tests}/ali_rds_backup_info_test.yml | 2 + .../tests}/ali_rds_backup_test.yml | 2 + ...ds_copy_database_between_instance_test.yml | 2 + .../tests}/ali_rds_database_info_test.yml | 2 + .../tests}/ali_rds_database_test.yml | 2 + .../tests}/ali_rds_instance_info_test.yml | 2 + .../tests}/ali_rds_instance_test.yml | 2 + .../tests}/ali_ros_info_test.yml | 0 {tests => plugins/tests}/ali_ros_test.yml | 0 .../tests}/ali_route_entry_test.yml | 2 + .../tests}/ali_security_group_info_test.yml | 2 + .../tests}/ali_security_group_test.yml | 2 + .../tests}/ali_slb_lb_info_test.yml | 2 + {tests => plugins/tests}/ali_slb_lb_test.yml | 2 + .../tests}/ali_slb_server_test.yml | 2 + {tests => plugins/tests}/ali_slb_tag_test.yml | 2 + .../tests}/ali_slb_vsg_info_test.yml | 2 + {tests => plugins/tests}/ali_slb_vsg_test.yml | 2 + {tests => plugins/tests}/ali_sts_test.yml | 0 {tests => plugins/tests}/ali_tags_test.yml | 0 .../tests}/ali_vpc_info_test.yml | 2 + {tests => plugins/tests}/ali_vpc_tag_test.yml | 2 + {tests => plugins/tests}/ali_vpc_test.yml | 4 +- .../tests}/ali_vswitch_info_test.yml | 2 + {tests => plugins/tests}/ali_vswitch_test.yml | 2 + {tests => plugins/tests}/destroy.yml | 0 {tests => plugins/tests}/group_vars/all | 0 plugins/tests/roles/__init__.py | 0 .../tests}/roles/disk/tasks/main.yml | 4 +- .../tests}/roles/dns/tasks/main.yml | 4 +- .../tests}/roles/dns_group/tasks/main.yml | 4 +- .../tests}/roles/eip/tasks/main.yml | 2 +- .../tests}/roles/instance/tasks/main.yml | 6 +- .../roles/network_interface/tasks/main.yml | 8 +- .../tests}/roles/rds/tasks/main.yml | 4 +- .../roles/security_group/tasks/main.yml | 4 +- .../tests}/roles/slb/tasks/main.yml | 4 +- .../tests}/roles/vpc/tasks/main.yml | 4 +- .../tests}/roles/vswitch/tasks/main.yml | 4 +- roles/ansible.cfg | 461 ------------ roles/hosts | 1 - roles/test_ecs.yml | 242 ------- roles/test_eni.yml | 215 ------ roles/test_ess.yml | 297 -------- roles/test_oss.yml | 97 --- roles/test_rds_account.yml | 81 --- roles/test_rds_instance.yml | 98 --- roles/test_slb.yml | 72 -- roles/test_slb_lb.yml | 74 -- roles/test_slb_listerner.yml | 75 -- roles/test_slb_test.yml | 74 -- roles/test_slb_vsg.yml | 71 -- roles/test_vpc.yml | 201 ------ setup.py | 63 -- 293 files changed, 1044 insertions(+), 15991 deletions(-) delete mode 100644 .gitignore delete mode 100644 .travis.yml delete mode 100644 CHANGELOG.md create mode 100644 COPYING delete mode 100644 LICENSE delete mode 100644 MANIFEST.in rename lib/__init__.py => __init__.py (100%) delete mode 100644 contrib/README.md delete mode 100644 docs/docsite/rst/dev_guide/developing_module_utilities.rst delete mode 100644 docs/docsite/rst/guide_alicloud.rst create mode 100644 galaxy.yml delete mode 100644 lib/CHANGELOG.md delete mode 100644 lib/MANIFEST.in delete mode 100644 lib/ansible/__init__.py delete mode 100644 lib/ansible/galaxy/deploy/.travis.yml delete mode 100644 lib/ansible/galaxy/deploy/README.md delete mode 100644 lib/ansible/galaxy/deploy/defaults/main.yml delete mode 100644 lib/ansible/galaxy/deploy/meta/main.yml delete mode 100644 lib/ansible/galaxy/deploy/tasks/create.yml delete mode 100644 lib/ansible/galaxy/deploy/tasks/deploy.yml delete mode 100644 lib/ansible/galaxy/deploy/tasks/main.yml delete mode 100644 lib/ansible/galaxy/deploy/tests/test.yml delete mode 100644 lib/ansible/galaxy/market/.travis.yml delete mode 100644 lib/ansible/galaxy/market/README.md delete mode 100644 lib/ansible/galaxy/market/defaults/main.yml delete mode 100644 lib/ansible/galaxy/market/meta/main.yml delete mode 100644 lib/ansible/galaxy/market/tasks/create.yml delete mode 100644 lib/ansible/galaxy/market/tasks/main.yml delete mode 100644 lib/ansible/galaxy/market/tasks/security.yml delete mode 100644 lib/ansible/galaxy/market/tasks/vpc.yml delete mode 100644 lib/ansible/galaxy/market/tasks/vswitch.yml delete mode 100644 lib/ansible/galaxy/market/tests/inventory delete mode 100644 lib/ansible/galaxy/market/tests/test.yml delete mode 100644 lib/ansible/galaxy/tags/.travis.yml delete mode 100644 lib/ansible/galaxy/tags/README.md delete mode 100644 lib/ansible/galaxy/tags/defaults/main.yml delete mode 100644 lib/ansible/galaxy/tags/handlers/main.yml delete mode 100644 lib/ansible/galaxy/tags/meta/main.yml delete mode 100644 lib/ansible/galaxy/tags/tasks/main.yml delete mode 100644 lib/ansible/galaxy/tags/tests/inventory delete mode 100644 lib/ansible/galaxy/tags/tests/test.yml delete mode 100644 lib/ansible/module_utils/__init__.py delete mode 100644 lib/ansible/modules/cloud/__init__.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_disk_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_eip_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_eni_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_image_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_instance_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_oss_bucket_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_oss_object_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_rds_account_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_rds_instance_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_route_entry_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_security_group_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_slb_lb_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_slb_listener_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_slb_server_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_slb_vsg_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_vpc_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_ali_vswitch_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_bucket.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_bucket_object.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_disk.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_disk_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_eip.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_ess_configuration.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_ess_group.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_ess_instance.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_ess_rule.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_ess_task.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_instance.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_instance_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_instance_type_facts.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_rds_account.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_route_entry.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_security_group.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_slb_lb.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_slb_listener.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_slb_server.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_slb_vsg.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_vpc.py delete mode 100644 lib/ansible/modules/cloud/alicloud/_alicloud_vswitch.py delete mode 100644 lib/ansible/utils/__init__.py delete mode 100644 lib/setup.py create mode 100644 plugins/README.md rename {lib/ansible/modules => plugins}/__init__.py (100%) rename {lib/ansible/modules/cloud/alicloud => plugins/doc_fragments}/__init__.py (100%) rename {lib/ansible/utils/module_docs_fragments => plugins/doc_fragments}/alicloud.py (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/LICENSE.md (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/README.md (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/alicloud.yml (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/destroy.yml (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/group_vars/all (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/roles/disk/tasks/main.yml (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/roles/instance/tasks/main.yml (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/roles/security_group/tasks/main.yml (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/roles/vpc/tasks/main.yml (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/roles/vswitch/tasks/main.yml (100%) rename {examples => plugins/examples}/alicloud-ecs-vpc/test.yml (100%) rename {examples => plugins/examples}/market/LICENSE.md (100%) rename {examples => plugins/examples}/market/README.md (100%) rename {examples => plugins/examples}/market/create.yml (100%) rename {examples => plugins/examples}/market/destroy.yml (100%) rename {examples => plugins/examples}/market/group_vars/all (100%) rename {examples => plugins/examples}/market/roles/security_group/tasks/main.yml (100%) rename {examples => plugins/examples}/market/roles/vpc/tasks/main.yml (100%) rename {examples => plugins/examples}/market/roles/vswitch/tasks/main.yml (100%) rename {examples => plugins/examples}/petstore/LICENSE.md (100%) rename {examples => plugins/examples}/petstore/README.md (100%) rename {examples => plugins/examples}/petstore/alicloud.ini (100%) rename {contrib/inventory => plugins/examples/petstore}/alicloud.py (100%) rename {examples => plugins/examples}/petstore/create.yml (100%) rename {examples => plugins/examples}/petstore/delete.yml (100%) rename {examples => plugins/examples}/petstore/deploy.yml (100%) rename {examples => plugins/examples}/petstore/group_vars/all (100%) rename {examples => plugins/examples}/petstore/roles/instance/tasks/main.yml (100%) rename {examples => plugins/examples}/petstore/roles/security_group/tasks/main.yml (100%) rename {examples => plugins/examples}/petstore/roles/vpc/tasks/main.yml (100%) rename {examples => plugins/examples}/petstore/roles/vswitch/tasks/main.yml (100%) rename {examples => plugins/examples}/tags/LICENSE.md (100%) rename {examples => plugins/examples}/tags/README.md (100%) rename {examples => plugins/examples}/tags/group_vars/all (100%) rename {examples => plugins/examples}/tags/tags.yml (100%) rename {lib/ansible/utils/module_docs_fragments => plugins/inventory}/__init__.py (100%) rename {lib/ansible/plugins => plugins}/inventory/alicloud.yml (97%) rename {lib/ansible/plugins => plugins}/inventory/alicloud_ecs.py (97%) create mode 100644 plugins/inventory/script/__init__.py rename {contrib/inventory => plugins/inventory/script}/alicloud.ini (100%) rename {examples/petstore => plugins/inventory/script}/alicloud.py (100%) create mode 100644 plugins/module_utils/__init__.py rename {lib/ansible => plugins}/module_utils/alicloud_ecs.py (100%) rename {lib/ansible => plugins}/module_utils/alicloud_oss.py (100%) create mode 100644 plugins/modules/__init__.py rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_disk.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_disk_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_dns_domain.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_dns_domain_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_dns_group.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_dns_group_info.py (96%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ecs_tag.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_eip.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_eip_info.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_eni.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_eni_info.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ess_configuration.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ess_group.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ess_instance.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ess_rule.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ess_task.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_image.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_image_info.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_instance.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_instance_info.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_instance_type_facts.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_market_product_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_oos_execution.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_oos_execution_info.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_oos_template.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_oos_template_info.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_oss_bucket.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_oss_bucket_info.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_oss_object.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_oss_object_info.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_access_key.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_access_key_info.py (95%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_group.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_group_info.py (96%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_login_profile.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_login_profile_info.py (95%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_policy.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_policy_info.py (96%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_role.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_role_info.py (96%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_user.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ram_user_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_rds_account.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_rds_account_info.py (96%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_rds_backup.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_rds_backup_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_rds_database.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_rds_database_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_rds_instance.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_rds_instance_info.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ros_stack.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_ros_stack_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_route_entry.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_route_entry_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_security_group.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_security_group_info.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_slb_lb.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_slb_lb_info.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_slb_listener.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_slb_listener_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_slb_server.py (99%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_slb_server_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_slb_tag.py (96%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_slb_vsg.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_slb_vsg_info.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_vpc.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_vpc_info.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_vpc_tag.py (97%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_vswitch.py (98%) rename {lib/ansible/modules/cloud/alicloud => plugins/modules}/ali_vswitch_info.py (98%) create mode 100644 plugins/tests/__init__.py rename {tests => plugins/tests}/ali_disk_info_test.yml (97%) rename {tests => plugins/tests}/ali_dns_domain_info_test.yml (91%) rename {tests => plugins/tests}/ali_dns_domain_test.yml (96%) rename {tests => plugins/tests}/ali_dns_group_info_test.yml (93%) rename {tests => plugins/tests}/ali_dns_group_test.yml (92%) rename {tests => plugins/tests}/ali_ecs_tag_test.yml (99%) rename {tests => plugins/tests}/ali_eip_info_test.yml (93%) rename {tests => plugins/tests}/ali_eip_test.yml (99%) rename {tests => plugins/tests}/ali_eni_info_test.yml (97%) rename {tests => plugins/tests}/ali_eni_test.yml (99%) rename {tests => plugins/tests}/ali_instance_info_test.yml (98%) rename {tests => plugins/tests}/ali_instance_prepaid_test.yml (99%) rename {tests => plugins/tests}/ali_instance_test.yml (99%) rename {tests => plugins/tests}/ali_market_product_test.yml (97%) rename {tests => plugins/tests}/ali_oos_execution_info_test.yml (98%) rename {tests => plugins/tests}/ali_oos_execution_test.yml (98%) rename {tests => plugins/tests}/ali_oos_template_info_test.yml (100%) rename {tests => plugins/tests}/ali_oos_template_test.yml (100%) rename {tests => plugins/tests}/ali_ram_access_key_info_test.yml (100%) rename {tests => plugins/tests}/ali_ram_access_key_test.yml (100%) rename {tests => plugins/tests}/ali_ram_group_info_test.yml (100%) rename {tests => plugins/tests}/ali_ram_group_test.yml (100%) rename {tests => plugins/tests}/ali_ram_login_profile_info_test.yml (100%) rename {tests => plugins/tests}/ali_ram_login_profile_test.yml (100%) rename {tests => plugins/tests}/ali_ram_policy_info_test.yml (100%) rename {tests => plugins/tests}/ali_ram_policy_test.yml (100%) rename {tests => plugins/tests}/ali_ram_profile_info_test.yml (100%) rename {tests => plugins/tests}/ali_ram_profile_test.yml (100%) rename {tests => plugins/tests}/ali_ram_role_info_test.yml (100%) rename {tests => plugins/tests}/ali_ram_role_test.yml (100%) rename {tests => plugins/tests}/ali_ram_user_info_test.yml (100%) rename {tests => plugins/tests}/ali_ram_user_test.yml (100%) rename {tests => plugins/tests}/ali_rds_account_info_test.yml (94%) rename {tests => plugins/tests}/ali_rds_account_test.yml (98%) rename {tests => plugins/tests}/ali_rds_backup_info_test.yml (94%) rename {tests => plugins/tests}/ali_rds_backup_test.yml (94%) rename {tests => plugins/tests}/ali_rds_copy_database_between_instance_test.yml (98%) rename {tests => plugins/tests}/ali_rds_database_info_test.yml (97%) rename {tests => plugins/tests}/ali_rds_database_test.yml (97%) rename {tests => plugins/tests}/ali_rds_instance_info_test.yml (96%) rename {tests => plugins/tests}/ali_rds_instance_test.yml (98%) rename {tests => plugins/tests}/ali_ros_info_test.yml (100%) rename {tests => plugins/tests}/ali_ros_test.yml (100%) rename {tests => plugins/tests}/ali_route_entry_test.yml (98%) rename {tests => plugins/tests}/ali_security_group_info_test.yml (96%) rename {tests => plugins/tests}/ali_security_group_test.yml (99%) rename {tests => plugins/tests}/ali_slb_lb_info_test.yml (96%) rename {tests => plugins/tests}/ali_slb_lb_test.yml (98%) rename {tests => plugins/tests}/ali_slb_server_test.yml (98%) rename {tests => plugins/tests}/ali_slb_tag_test.yml (97%) rename {tests => plugins/tests}/ali_slb_vsg_info_test.yml (98%) rename {tests => plugins/tests}/ali_slb_vsg_test.yml (99%) rename {tests => plugins/tests}/ali_sts_test.yml (100%) rename {tests => plugins/tests}/ali_tags_test.yml (100%) rename {tests => plugins/tests}/ali_vpc_info_test.yml (96%) rename {tests => plugins/tests}/ali_vpc_tag_test.yml (98%) rename {tests => plugins/tests}/ali_vpc_test.yml (98%) rename {tests => plugins/tests}/ali_vswitch_info_test.yml (97%) rename {tests => plugins/tests}/ali_vswitch_test.yml (98%) rename {tests => plugins/tests}/destroy.yml (100%) rename {tests => plugins/tests}/group_vars/all (100%) create mode 100644 plugins/tests/roles/__init__.py rename {tests => plugins/tests}/roles/disk/tasks/main.yml (93%) rename {tests => plugins/tests}/roles/dns/tasks/main.yml (72%) rename {tests => plugins/tests}/roles/dns_group/tasks/main.yml (71%) rename {tests => plugins/tests}/roles/eip/tasks/main.yml (85%) rename {tests => plugins/tests}/roles/instance/tasks/main.yml (92%) rename {tests => plugins/tests}/roles/network_interface/tasks/main.yml (86%) rename {tests => plugins/tests}/roles/rds/tasks/main.yml (85%) rename {tests => plugins/tests}/roles/security_group/tasks/main.yml (82%) rename {tests => plugins/tests}/roles/slb/tasks/main.yml (87%) rename {tests => plugins/tests}/roles/vpc/tasks/main.yml (80%) rename {tests => plugins/tests}/roles/vswitch/tasks/main.yml (84%) delete mode 100644 roles/ansible.cfg delete mode 100644 roles/hosts delete mode 100644 roles/test_ecs.yml delete mode 100644 roles/test_eni.yml delete mode 100644 roles/test_ess.yml delete mode 100644 roles/test_oss.yml delete mode 100644 roles/test_rds_account.yml delete mode 100644 roles/test_rds_instance.yml delete mode 100644 roles/test_slb.yml delete mode 100644 roles/test_slb_lb.yml delete mode 100644 roles/test_slb_listerner.yml delete mode 100644 roles/test_slb_test.yml delete mode 100644 roles/test_slb_vsg.yml delete mode 100644 roles/test_vpc.yml diff --git a/.gitignore b/.gitignore deleted file mode 100644 index cfc6a832..00000000 --- a/.gitignore +++ /dev/null @@ -1,111 +0,0 @@ -# build products... -*.py[co] -build -AUTHORS.TXT -# Emacs backup files... -*~ -.\#* -# RPM stuff... -MANIFEST -dist -rpm-build -# Eclipse/PyDev stuff... -.project -.pydevproject -# PyCharm stuff... -.idea -#IntelliJ IDEA stuff.. -*.iml -# Mac OS X stuff... -.DS_Store -# manpage build stuff... -docs/man/man1/ansible*.1 -docs/man/man1/ansible*.1.asciidoc.in -docs/man/man3/* -# Sublime stuff -*.sublime-project -*.sublime-workspace -# docsite stuff... -docs/docsite/rst/modules_by_category.rst -docs/docsite/rst/playbooks_directives.rst -docs/docsite/rst/playbook_keywords.rst -docs/docsite/rst/list_of_*.rst -docs/docsite/rst/*_module.rst -docs/docsite/*.html -docs/docsite/_static/*.gif -docs/docsite/_static/*.png -docs/docsite/_static/websupport.js -docs/docsite/searchindex.js -docs/docsite/htmlout -docs/docsite/_build -docs/api/rst/ -docs/api/_build/ -# deb building stuff... -/debian/ -deb-build -# Vim swap files -*.swp -*.swo -credentials.yml -# test output -*.retry -*.out -.tox -.cache -results.xml -coverage.xml -/test/units/cover-html -/test/integration/targets/*/backup/ -# Development -/test/develop -venv -Vagrantfile -.vagrant -ansible.egg-info/ -/shippable/ -# Release directory -packaging/release/ansible_release -/.cache/ -/test/results/coverage/*=coverage.* -/test/results/coverage/coverage* -/test/results/reports/coverage*.xml -/test/results/reports/coverage*/ -/test/results/bot/*.json -/test/results/junit/*.xml -/test/results/logs/*.log -/test/integration/inventory.remote -/test/integration/inventory.networking -/test/integration/inventory.winrm -# python 'rope' stuff -.ropeproject -# local 'ack' config files -.ackrc -# default 'coverage html' results -htmlcov/ -# default 'coverage' tool data -.coverage -# ansible-test coverage results -test/units/.coverage.* - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib64/ -parts/ -sdist/ -var/ -*.egg-info/ -.installed.cfg -*.egg - -*~HEAD -*~reback -*.cache -*.index -*.bak diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7f412167..00000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -sudo: required -dist: trusty -language: python -python: - - "2.7" -services: - - docker -env: - global: - - PATH="/usr/bin:$PATH" - -before_install: - # Ansible doesn't play well with virtualenv - - deactivate - - sudo apt-get update -qq - - sudo apt-get install -y -o Dpkg::Options::="--force-confnew" docker-engine - -install: - - sudo pip install docker-py - - sudo -H pip install roles/packages/footmark-1.0.8.tar.gz - - sudo -H pip install roles/packages/ecsutils-1.0.4.tar.gz - - sudo -H pip install roles/packages/ossutils-1.0.0.tar.gz - # software-properties-common for ubuntu 14.04 - # python-software-properties for ubuntu 12.04 - - sudo apt-get install -y sshpass software-properties-common python-software-properties - - sudo apt-add-repository -y ppa:ansible/ansible - - sudo apt-get update -qq - - sudo apt-get install -y ansible - - sudo rm /usr/bin/python && sudo ln -s /usr/bin/python2.7 /usr/bin/python - - ansible --version - - -script: - - ansible-playbook -i roles/hosts -M module/ roles/test_ecs.yml - - ansible-playbook -i roles/hosts -M module/ roles/test_slb.yml - - ansible-playbook -i roles/hosts -M module/ roles/test_vpc.yml - - ansible-playbook -i roles/hosts -M module/ roles/test_oss.yml - - ansible-playbook -i roles/hosts -M module/ roles/test_rds.yml diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 6f28477d..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,288 +0,0 @@ -# Ansible-Alicloud Change Log -## 1.20.0 (Unreleased) - -## 1.19.0 (22 April, 2020) -- Add resource_id for some modules ([#260](https://github.com/alibaba/ansible-provider/pull/260)) -- Add new module ali_ros_stack ([#263](https://github.com/alibaba/ansible-provider/pull/263)) -- improve ros: del ros_stack_info stacknames ([#266](https://github.com/alibaba/ansible-provider/pull/266)) -- improve instance: Format module instance ([#267](https://github.com/alibaba/ansible-provider/pull/267)) -- Format some utils ([#268](https://github.com/alibaba/ansible-provider/pull/268)) -- Add new module oos ([#259](https://github.com/alibaba/ansible-provider/pull/259)) -- Format modules ([#269](https://github.com/alibaba/ansible-provider/pull/269)) - -## 1.18.0 (20 March, 2020) -- improve(ali_instance): support modify instance charge type ([#256](https://github.com/alibaba/ansible-provider/pull/256)) -- improve(disk_info): Add some new params and Add test case ([#248](https://github.com/alibaba/ansible-provider/pull/248)) -- improve(disk): Add filters param ([#249](https://github.com/alibaba/ansible-provider/pull/249)) -- improve(slb): support server_ids ([#250](https://github.com/alibaba/ansible-provider/pull/250)) -- Add plugin alicloud_ecs and configuration file ([#252](https://github.com/alibaba/ansible-provider/pull/252)) -- Add module ali_ecs_tag ([#254](https://github.com/alibaba/ansible-provider/pull/254)) -- improve(eip/eni/vpc/ecs/security/slb/vsw): format code and doc ([#251](https://github.com/alibaba/ansible-provider/pull/251)) -- improve(disk/dns/ram/rds/slb): format code and doc ([#253](https://github.com/alibaba/ansible-provider/pull/253)) - -## 1.17.0 (1 March, 2020) -- Add new module ali_market_product_info ([#240](https://github.com/alibaba/ansible-provider/pull/240)) -- Add example tags ([#236](https://github.com/alibaba/ansible-provider/pull/236)) -- improve(example/tags): remove create resource ([#241](https://github.com/alibaba/ansible-provider/pull/241)) -- deploy petstore on ECS ([#238](https://github.com/alibaba/ansible-provider/pull/238)) -- Add market example ([#242](https://github.com/alibaba/ansible-provider/pull/242)) -- improve market example ([#244](https://github.com/alibaba/ansible-provider/pull/244)) -- improve(example/petstore): Add ini file ([#244](https://github.com/alibaba/ansible-provider/pull/244)) -- improve(example/petstore): Add alicloud.py file ([#245](https://github.com/alibaba/ansible-provider/pull/245)) - -## 1.16.1 (28 February, 2020) -- modify footmark version ([#239](https://github.com/alibaba/ansible-provider/pull/239)) - -## 1.16.0 (27 February, 2020) -- improve(ram): Add ram module ([#227](https://github.com/alibaba/ansible-provider/pull/227)) -- Add new modules ali_ecs_tag ali_slb_tag ali_vpc_tag ([#235](https://github.com/alibaba/ansible-provider/pull/235)) - -## 1.15.0 (31 January, 2020) -- fix inventory bug use ecs role name ([#230](https://github.com/alibaba/ansible-provider/pull/230)) -- improve(rds): Add rds policy module ([#221](https://github.com/alibaba/ansible-provider/pull/221)) -- improve(rds): Modify rds account module ([#222](https://github.com/alibaba/ansible-provider/pull/222)) -- improve(rds): Add rds backup module ([#223](https://github.com/alibaba/ansible-provider/pull/223)) -- improve(ecs): add new param unique_suffix ([#228](https://github.com/alibaba/ansible-provider/pull/228)) -- improve (rds): modify rds instance and database ([#205](https://github.com/alibaba/ansible-provider/pull/205)) -- fix inventory bug ([#217](https://github.com/alibaba/ansible-provider/pull/217)) -- improve(slb): Add tags ([#219](https://github.com/alibaba/ansible-provider/pull/219)) - -## 1.14.0 (11 December, 2019) -- support profile authentication ([#208](https://github.com/alibaba/ansible-provider/pull/208)) -- improve(inventory): Support more authentication methods ([#209](https://github.com/alibaba/ansible-provider/pull/209)) - -## 1.13.0 (3 December, 2019) -- Add new module ali_dns_domain, ali_dns_domain_info and test case([#201](https://github.com/alibaba/ansible-provider/pull/201)) -- Add new module ali_dns_group, ali_dns_group_info and test case ([#202](https://github.com/alibaba/ansible-provider/pull/202)) -- improve(ecs): change method create_instances to run_instances ([#194](https://github.com/alibaba/ansible-provider/pull/194)) - -## 1.12.1 (13 November, 2019) -- improve(ecs): improve(ecs): support create spot instance ([#196](https://github.com/alibaba/ansible-provider/pull/196)) -- improve(slb): Fix the error of passing parameters and add testcase ([#199](https://github.com/alibaba/ansible-provider/pull/199)) - -## 1.12.0 (12 November, 2019) - -IMPROVEMENTS: -- support modify route entry's name ([#179](https://github.com/alibaba/ansible-provider/pull/179)) -- support query instance more than 10 results ([#182](https://github.com/alibaba/ansible-provider/pull/182)) -- change facts to info ([#183](https://github.com/alibaba/ansible-provider/pull/183)) -- fix ali_eni module bug caused by not passing description ([#188](https://github.com/alibaba/ansible-provider/pull/188)) -- resolve warning of the same name ([#186](https://github.com/alibaba/ansible-provider/pull/186)) -- add 'try in cloud shell' button into readme ([#182](https://github.com/alibaba/ansible-provider/pull/182)) -- add ram_role_name param for ecs ([#190](https://github.com/alibaba/ansible-provider/pull/190)) -- support ecs role name ([#191](https://github.com/alibaba/ansible-provider/pull/191)) -- support assume role ([#189](https://github.com/alibaba/ansible-provider/pull/189)) -- improve(vpc): add tags param ([#192](https://github.com/alibaba/ansible-provider/pull/192)) - -## 1.11.0 (October 16, 2019) - -IMPROVEMENTS: - -- improve example alicloud-ecs-vpc ([#175](https://github.com/alibaba/ansible-provider/pull/175)) -- improve code to python3 ([#176](https://github.com/alibaba/ansible-provider/pull/176)) -- Add ali_route_entry test case ([#177](https://github.com/alibaba/ansible-provider/pull/177)) - -BUG FIXES: - -- Fix create_instance's max_bandwidth_in error ([#177](https://github.com/alibaba/ansible-provider/pull/177)) - -## 1.10.0 (11 July, 2019) - -IMPROVEMENTS: - -- Publish release 1.10.0 ([#172](https://github.com/alibaba/ansible-provider/pull/172)) -- Sync alicloud instance modules with the latest ansible ([#171](https://github.com/alibaba/ansible-provider/pull/171)) -- Match the latest method describe_instances in footmark 1.12.0 ([#171](https://github.com/alibaba/ansible-provider/pull/171)) -- Add creation_time attribute in ali_image_facts results ([#164](https://github.com/alibaba/ansible-provider/pull/164)) - -BUG FIXES: - -- Fix incorrect destination address when hostname_variable equals with destination_address ([#170](https://github.com/alibaba/ansible-provider/pull/170)) -- Fix grouping dynamic inventory on security group bug ([#169](https://github.com/alibaba/ansible-provider/pull/169)) -- Default to describe all instances in all regions ([#158](https://github.com/alibaba/ansible-provider/pull/158)) -- Fix ecs_instance_filters last page describe bug ([#157](https://github.com/alibaba/ansible-provider/pull/157)) -- Fix ecs_instance_filters's page_size bug ([#156](https://github.com/alibaba/ansible-provider/pull/156)) - -## 1.9.0 (4 January, 2019) - -FEATURES: - -- **New Module:** `ali_eip_facts` ([#144](https://github.com/alibaba/ansible-provider/pull/144)) - -IMPROVEMENTS: - -- Improve test cases ([#154](https://github.com/alibaba/ansible-provider/pull/154)) -- Improve inventory alicloud.py meta and use public_ip_address instead eip_address ([#152](https://github.com/alibaba/ansible-provider/pull/152)) -- Improve module ali_vpc and ali_security_group multi_ok ([#149](https://github.com/alibaba/ansible-provider/pull/149)) -- Improve module ali_slb_vsg and ali_slb_vsg_facts ([#148](https://github.com/alibaba/ansible-provider/pull/148)) -- Improve module ali_slb_lb and ali_slb_lb_facts ([#147](https://github.com/alibaba/ansible-provider/pull/147)) -- Improve ecs instance and eni docs ([#146](https://github.com/alibaba/ansible-provider/pull/146)) -- Improve module ali_eip and add its testcase ([#145](https://github.com/alibaba/ansible-provider/pull/145)) -- Improve dynamic inventory by setting page_size 100 ([#142](https://github.com/alibaba/ansible-provider/pull/142)) -- Improve ali_security_group and make it idempotence ([#137](https://github.com/alibaba/ansible-provider/pull/137)) -- Improve ali_vswitch and make it idempotence ([#136](https://github.com/alibaba/ansible-provider/pull/136)) -- Improve ali_vpc and make it idempotence ([#135](https://github.com/alibaba/ansible-provider/pull/135)) - -BUG FIXES: - -- Fix regions=all not working bug in dynamic inventory ([#141](https://github.com/alibaba/ansible-provider/pull/141)) - -## 1.8.0 (12 November, 2018) - -IMPROVEMENTS: - -- Improve examples/alicloud-ecs-vpc ([#133](https://github.com/alibaba/ansible-provider/pull/133)) -- Improve filters ([#132](https://github.com/alibaba/ansible-provider/pull/132)) -- Add tags for ali_eni ([#131](https://github.com/alibaba/ansible-provider/pull/131)) -- Improve module ali_eni and ali_eni_facts ([#130](https://github.com/alibaba/ansible-provider/pull/130)) -- Add test cases for the ali_eni and ali_eni_facts([#130](https://github.com/alibaba/ansible-provider/pull/130)) -- Add name_prefix and tags for the ali_eni_facts ([#130](https://github.com/alibaba/ansible-provider/pull/130)) -- Improve module ali_eni and ali_eni_facts ([#130](https://github.com/alibaba/ansible-provider/pull/130)) -- Improve dynamic inventory grammar ([#128](https://github.com/alibaba/ansible-provider/pull/128)) - -BUG FIXES: - -- Fix ali_security_group_facts's tags invalid ([#130](https://github.com/alibaba/ansible-provider/pull/130)) - -## 1.7.0 (2 November, 2018) - -IMPROVEMENTS: - -- Add tags for ali_security_group ([#127](https://github.com/alibaba/ansible-provider/pull/127)) -- Add name_prefix for ali_security_group_facts ([#127](https://github.com/alibaba/ansible-provider/pull/127)) -- Add name_prefix and cidr_prefix for ali_vpc_facts ([#126](https://github.com/alibaba/ansible-provider/pull/126)) -- Add name_prefix and filters for ali_instance_facts ([#125](https://github.com/alibaba/ansible-provider/pull/125)) -- Improve alicloud inventory based on footmark 1.6.3+ ([#124](https://github.com/alibaba/ansible-provider/pull/124)) -- Improve ali_security_group and support purge_rules and purge_rules_egress ([#123](https://github.com/alibaba/ansible-provider/pull/123)) - -## 1.6.0 (October 30, 2018) - -IMPROVEMENTS: - -- Add alias for security_groups and availability_zone ([#122](https://github.com/alibaba/ansible-provider/pull/122)) -- Improve ali_vpc, ali_vpc_facts, ali_vswitch and ali_vswitch_facts using footmark 1.6.0 ([#121](https://github.com/alibaba/ansible-provider/pull/121)) -- Add ali_vpc and ali_vswitch test case ([#121](https://github.com/alibaba/ansible-provider/pull/121)) -- Add purge_tags for ali_instance ([#119](https://github.com/alibaba/ansible-provider/pull/119)) -- Improve ali_instance, ali_instance_facts, ali_security_group and ali_ali_security_group_facts using footmark 1.6.0 ([#119](https://github.com/alibaba/ansible-provider/pull/119)) -- Add ali_instance test case ([#119](https://github.com/alibaba/ansible-provider/pull/119)) -- Add destroy.yml for examples/alicloud_ecs_vpc ([#117](https://github.com/alibaba/ansible-provider/pull/117)) -- Improve roles test cases ([#116](https://github.com/alibaba/ansible-provider/pull/116)) -- Improve example/alicloud-ecs-vpc ([#114](https://github.com/alibaba/ansible-provider/pull/114), [#115](https://github.com/alibaba/ansible-provider/pull/115)) -- Change nested_groups default to False ([#113](https://github.com/alibaba/ansible-provider/pull/113git )) -- Add to_safe method for dynamic inventory ([#112](https://github.com/alibaba/ansible-provider/pull/112)) - -BUG FIXED: - -- Fix ali_instance_facts filter is None bug ([#120](https://github.com/alibaba/ansible-provider/pull/120)) -- Correct module docs ([#103](https://github.com/alibaba/ansible-provider/pull/103)) -- Fix nested_groups bug ([#111](https://github.com/alibaba/ansible-provider/pull/111)) - - -## 1.5.0 (July 4, 2018) - -IMPROVEMENTS: - -- **New Module:** ali_eni ([#102](https://github.com/alibaba/ansible-provider/pull/102)) -- **New Module:** ali_eni_facts ([#102](https://github.com/alibaba/ansible-provider/pull/102)) -- Rename all module prefix and use 'ali' instead ([#102](https://github.com/alibaba/ansible-provider/pull/102)) -- Improve README ([#88](https://github.com/alibaba/ansible-provider/pull/88)) - -IMPROVEMENTS: - -- Improve README ([#88](https://github.com/alibaba/ansible-provider/pull/88)) - -## 1.3.2 (January 23, 2018) - -BUG FIXED: - - * fix creating multiple security group error from [issue 82](https://github.com/alibaba/ansible-provider/issues/82) ([#82](https://github.com/alibaba/ansible-provider/pull/82)) - -## 1.3.0 (January 23, 2018) - -Pip package is unavailable. - -## 1.3.0 (January 10, 2018) - -IMPROVEMENTS: - - * **New Module:** alicloud_ess_rule ([#81](https://github.com/alibaba/ansible-provider/pull/81)) - * **New Module:** alicloud_ess_task ([#81](https://github.com/alibaba/ansible-provider/pull/81)) - * Remove all ECS instances in the specified ESS Group ([#81](https://github.com/alibaba/ansible-provider/pull/81)) - * Modify alicloud_ess_instance to remove all instances in the ESS Group ([#81](https://github.com/alibaba/ansible-provider/pull/81)) - - -## 1.2.0 (January 8, 2018) - -IMPROVEMENTS: - - * **New Module:** alicloud_ess_group ([#79](https://github.com/alibaba/ansible-provider/pull/79)) - * **New Module:** alicloud_ess_configuration ([#79](https://github.com/alibaba/ansible-provider/pull/79)) - * **New Module:** alicloud_ess_instance ([#79](https://github.com/alibaba/ansible-provider/pull/79)) - * Update module 'alicloud_slb_listener' examples spelling error: ([#80](https://github.com/alibaba/ansible-provider/pull/80)) - - -## 1.1.3 (December 20, 2017) - -IMPROVEMENTS: - - * alicloud_slb_lb: remove status and add start/stop slb instance ([#78](https://github.com/alibaba/ansible-provider/pull/78)) - -BUG FIXED: - - * alicloud_slb_listener: fix listener not found ([#78](https://github.com/alibaba/ansible-provider/pull/78)) - - -## 1.1.1 (November 13, 2017) - -NEW RESOURCE MODULES: - - * alicloud_eip: new module for EIP ([#76](https://github.com/alibaba/ansible-provider/pull/76)) - -## 1.0.12 (November 6, 2017) - -IMPROVEMENTS: - - * alicloud_instance: add key pair and userdata ([#69](https://github.com/alibaba/ansible-provider/pull/69)) - - -## 1.0.12 (November 6, 2017) - -IMPROVEMENTS: - - * alicloud_instance: add key pair and userdata ([#69](https://github.com/alibaba/ansible-provider/pull/69)) - - -## 1.0.12 (November 6, 2017) - -IMPROVEMENTS: - - * alicloud_instance: add key pair and userdata ([#69](https://github.com/alibaba/ansible-provider/pull/69)) - - -## 1.0.11 (November 2, 2017) - -IMPROVEMENTS: - - * add client token for disk, group, vpc, vswitch, slb and rds ([#67](https://github.com/alibaba/ansible-provider/pull/67)) - * modify footmark version for all module ([#67](https://github.com/alibaba/ansible-provider/pull/67)) - - -## 1.0.10 (November 2, 2017) - -IMPROVEMENTS: - - * alicloud/alicloud_instance.py: add client_token and improve code according to Ansible official ([#67](https://github.com/alibaba/ansible-provider/pull/67)) - - -## 1.0.9(October 24, 2016) - - * **New Module:** `alicloud_instance` - * **New Module:** `alicloud_security_group` - * **New Module:** `alicloud_slb` - * **New Module:** `alicloud_vpc` - * **New Module:** `alicloud_vswitch` - * **New Module:** `alicloud_route_entry` - * **New Module:** `alicloud_bucket` - * **New Module:** `alicloud_bucket_object` - * **New Module:** `alicloud_instance_facts` - * **New Module:** `alicloud_instance_type_facts` diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..10926e87 --- /dev/null +++ b/COPYING @@ -0,0 +1,675 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 56a3616a..00000000 --- a/LICENSE +++ /dev/null @@ -1,190 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - Copyright 2016-2016 Alibaba Group Holding Limited. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 0e4c55eb..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -prune ticket_stubs -prune hacking - -exclude lib/ansible/setup.py -exclude *.egg-info -exclude ansible/dist diff --git a/README.md b/README.md index 437ce54d..8852d7f8 100644 --- a/README.md +++ b/README.md @@ -1,67 +1,76 @@ -# Ansible ECS Module - -Ansible Alicloud Module is a new ansible module, and you can manage Alicloud ECS and other services more flexibly and conveniently via it. Next to introduce simply this module. - - - - - -## lib/ansible/modules/cloud/alicloud -There are several files in the module directory, and these files describe some function that can operate alicloud products. - -- `ali_instance.py`: Create, Start, Stop, Restart or Terminate an Instance in ECS. Add or Remove Instance to/from a Security Group -- `ali_disk.py`: Create, Attach, Detach or Delete a disk in ECS -- `ali_security_group.py`: Create or Delete a Security Group -- `ali_vpc.py`: Create or Delete a Vpc. -- `ali_vswitch.py`: Create or Delete a VSwitch. -- `ali_route_entry.py`: Create or Delete a route entry. -- `ali_slb_lb.py`: Create or Delete a Load balancer. -- `ali_slb_listener.py`: Create or Delete a listener for one Load balancer. -- `ali_slb_server.py`: Add or Remove backend server to/from Load balancer. -- `ali_ess_group.py`: Create or Delete a scaling group. -- `ali_ess_configuration.py`: Create or Delete a scaling configuration. -- `ali_ess_instance.py`: Add or Remove ECS instnaces in a specified scaling group. -- `ali_ess_task.py`: Create or Delete a scheduled task for scaling activity. -- `ali_ess_rule.py`: Create or Delete a scaling rule. -- `ali_eni.py`: Create or Delete a network interface. -- `ali_bucket.py`: Create or Delete an OSS bucket. -- `ali_bucket_object.py`: Upload or Download an object to/from an OSS bucket. - -## lib/ansible/module_utils -In the module utils directory, the file alicloud_ecs.py identifies and gains playbook params, and provides this params to modules/*.py. In addition, this file implements connection between ansible and Alicloud API via footmark. - -## examples -There are some playbooks to create some alicloud resource or build infrastructure architecture. - -### Install -There are two ways to install alicloud provider. However, before installing it. you should ensure `Ansible` has existed in your server. -If not, please install it using the following command: - - sudo pip install ansible - -* First one - - Ansible provider has been released, and you can install it easily using the following command: - - sudo pip install ansible_alicloud - -* Second one - - Ansible provider's modules support to install independently. That means you can download one or more modules from lib/ansible/modules/cloud/alicloud and then run them independently. - However, before running them, you should ensure `ansible_alicloud_module_utils` has existed in your server. If not, please install it using the following command: - - sudo pip install ansible_alicloud_module_utils - -### Execute playbook - -* Input your alicloud access key in the playbook or set environment variable:`ALICLOUD_ACCESS_KEY` and `ALICLOUD_SECRET_KEY`). -* Input others resource params in the playbook. -* execute ansible-playbook command as follows: - - $ ansible-playbook xxx.yml - -## Refrence - +# Ansible Collection - alibaba.alicloud + +## Installation and Usage +#### Installing the Collection from Ansible Galaxy +Before using the alicloud collection, you need to install the collection with the ansible-galaxy CLI: +``` +ansible-galaxy collection install alibaba.alicloud +``` +#### Installing dependency footmark +``` +pip install footmark +``` + +#### Usage +``` +collections: +- name: alibaba.alicloud +``` + +## Include modules +- `ali_instance`: Create, Start, Stop, Restart or Terminate an Instance in ECS. Add or Remove Instance to/from a Security Group +- `ali_disk`: Create, Attach, Detach or Delete a disk in ECS +- `ali_dns_domian`: Create, Delete and Update DNS domain +- `ali_dns_group`: Create, Delete and Update DNS group +- `ali_ecs_tag`: Add tags for alicloud resource +- `ali_eip`: Create eip address and bind it to a specified device +- `ali_image`: Create or delete user-defined image +- `ali_market_product_info`: Gather info on Market product of alicloud +- `ali_oos_execution`: Create, Delete, Notify, Cancel OOS Execution +- `ali_oos_template`: Create, Delete, Update OOS template +- `ali_oss_bucket`: Create, Delete, Retrieve Bucket +- `ali_oss_object`: Uploading and Downloading objects, Retrieving object keys +- `ali_ram_access_key`: Create, Delete Ram Access Key and Update status +- `ali_ram_group`: Create, Delete, Update Ram group +- `ali_ram_login_profile`: Create, Delete, Update Ram login profile +- `ali_ram_policy`: Create, Delete, Attach and Detach Ram policy +- `ali_ram_role`: Create, Delete, Update Ram Role +- `ali_ram_user`: Create, Delete, Update Ram User +- `ali_rds_account`: Create, Delete, Modyfy, Reset rds account and Grant, Revoke privilege +- `ali_rds_backup`: Create, Delete rds backup +- `ali_rds_database`: Create, Delete or Copy an rds database +- `ali_rds_instance`: Create, Restart or Delete an RDS Instance +- `ali_ros_stack`: Create, Delete and Modify for ROS Stack +- `ali_security_group`: Create or Delete a Security Group +- `ali_vpc.py`: Create or Delete a Vpc +- `ali_vswitch`: Create or Delete a VSwitch +- `ali_route_entry`: Create or Delete a route entry +- `ali_slb_lb`: Create or Delete a Load balancer +- `ali_slb_listener`: Create or Delete a listener for one Load balancer +- `ali_slb_server`: Add or Remove backend server to/from Load balancer +- `ali_slb_vsg`: Create and delete a VServer group +- `ali_ess_group`: Create or Delete a scaling group +- `ali_ess_configuration`: Create or Delete a scaling configuration +- `ali_ess_instance`: Add or Remove ECS instnaces in a specified scaling group +- `ali_ess_task`: Create or Delete a scheduled task for scaling activity +- `ali_ess_rule`: Create or Delete a scaling rule +- `ali_eni`: Create or Delete a network interface + + +## Inventory plugin +#### Usage +config file +``` +alicloud.yaml + +plugin: alibaba.alicloud.alicloud_ecs +``` +Execute command line +``` +ansible-inventory -i alicloud.yml --graph +``` + +## DOC Ansible Document: https://docs.ansible.com/ansible/latest/ -Ansible Alicloud: [Docs Details](http://47.88.222.42:8080/ansible-alicloud/latest/modules/list_of_cloud_modules.html) +Ansible Alicloud: [Docs Details](http://47.88.222.42:8080/ansible-alicloud/latest/modules/list_of_cloud_modules.html) \ No newline at end of file diff --git a/lib/__init__.py b/__init__.py similarity index 100% rename from lib/__init__.py rename to __init__.py diff --git a/contrib/README.md b/contrib/README.md deleted file mode 100644 index 4c3082ad..00000000 --- a/contrib/README.md +++ /dev/null @@ -1,26 +0,0 @@ -contrib -------- -Files here provide an extension mechanism for Ansible similar to plugins. They are not maintained by the Ansible core team or installed with Ansible. - - -inventory -========= - -Before 2.4 introduced inventory plugins, inventory scripts were the only way to provide sources that were not built into Ansible. Inventory scripts allow you to store your hosts, groups, and variables in any way you like. - -Starting with Ansible version 2.4, they are enabled via the 'script' inventory plugin. -Examples of use include discovering inventory from EC2 or pulling it from Cobbler. These could also be used to interface with LDAP or the database. - -`chmod +x` an inventory plugin and either name it `/etc/ansible/hosts` or use `ansible -i /path/to/inventory/script`. You might also need to copy a configuration file with the same name and/or set environment variables. The scripts or configuration files can provide more details. - -vault -===== - -If the file passed to `--vault-password-file` has the executable bit set, Ansible will execute it and use the stdout of that execution as 'the secret'. -Vault scripts provided here use this facility to retrieve the vault secret from a number of sources. - -contributions welcome -===================== - -Send in pull requests to add scripts of your own. The sky is the limit! - diff --git a/docs/docsite/rst/dev_guide/developing_module_utilities.rst b/docs/docsite/rst/dev_guide/developing_module_utilities.rst deleted file mode 100644 index 95a179ec..00000000 --- a/docs/docsite/rst/dev_guide/developing_module_utilities.rst +++ /dev/null @@ -1,54 +0,0 @@ -Appendix: Module Utilities -`````````````````````````` - -Ansible provides a number of module utilities that provide helper functions that you can use when developing your own modules. The `basic.py` module utility provides the main entry point for accessing the Ansible library, and all Ansible modules must, at minimum, import from basic.py:: - - from ansible.module_utils.basic import * - - -The following is a list of module_utils files and a general description. The module utility source code lives in the `./lib/module_utils` directory under your main Ansible path - for more details on any specific module utility, please see the source code. - -- a10.py - Utilities used by the a10_server module to manage A10 Networks devices. -- aireos.py - Definitions and helper functions for modules that manage Cisco WLC devices. -- alicloud_ecs.py - Definitions and utilities for modules working with Alicloud ECS. -- api.py - Adds shared support for generic API modules. -- aos.py - Module support utilities for managing Apstra AOS Server. -- aruba.py - Helper functions for modules working with Aruba networking devices. -- asa.py - Module support utilities for managing Cisco ASA network devices. -- azure_rm_common.py - Definitions and utilities for Microsoft Azure Resource Manager template deployments. -- basic.py - General definitions and helper utilities for Ansible modules. -- cloudstack.py - Utilities for CloudStack modules. -- database.py - Miscellaneous helper functions for PostGRES and MySQL -- docker_common.py - Definitions and helper utilities for modules working with Docker. -- ec2.py - Definitions and utilities for modules working with Amazon EC2 -- eos.py - Helper functions for modules working with EOS networking devices. -- f5.py - Helper functions for modules working with F5 networking devices. -- facts.py - Helper functions for modules that return facts. -- gce.py - Definitions and helper functions for modules that work with Google Compute Engine resources. -- ios.py - Definitions and helper functions for modules that manage Cisco IOS networking devices -- iosxr.py - Definitions and helper functions for modules that manage Cisco IOS-XR networking devices -- ismount.py - Contains single helper function that fixes os.path.ismount -- junos.py - Definitions and helper functions for modules that manage Junos networking devices -- known_hosts.py - utilities for working with known_hosts file -- mysql.py - Allows modules to connect to a MySQL instance -- netapp.py - Functions and utilities for modules that work with the NetApp storage platforms. -- netcfg.py - Configuration utility functions for use by networking modules -- netcmd.py - Defines commands and comparison operators for use in networking modules -- netscaler.py - Utilities specifically for the netscaler network modules. -- network.py - Functions for running commands on networking devices -- nxos.py - Contains definitions and helper functions specific to Cisco NXOS networking devices -- openstack.py - Utilities for modules that work with Openstack instances. -- openswitch.py - Definitions and helper functions for modules that manage OpenSwitch devices -- powershell.ps1 - Utilities for working with Microsoft Windows clients -- pure.py - Functions and utilities for modules that work with the Pure Storage storage platforms. -- pycompat24.py - Exception workaround for Python 2.4. -- rax.py - Definitions and helper functions for modules that work with Rackspace resources. -- redhat.py - Functions for modules that manage Red Hat Network registration and subscriptions -- service.py - Contains utilities to enable modules to work with Linux services (placeholder, not in use). -- shell.py - Functions to allow modules to create shells and work with shell commands -- six/__init__.py - Bundled copy of the `Six Python library `_ to aid in writing code compatible with both Python 2 and Python 3. -- splitter.py - String splitting and manipulation utilities for working with Jinja2 templates -- urls.py - Utilities for working with http and https requests -- vca.py - Contains utilities for modules that work with VMware vCloud Air -- vmware.py - Contains utilities for modules that work with VMware vSphere VMs -- vyos.py - Definitions and functions for working with VyOS networking diff --git a/docs/docsite/rst/guide_alicloud.rst b/docs/docsite/rst/guide_alicloud.rst deleted file mode 100644 index 77a23902..00000000 --- a/docs/docsite/rst/guide_alicloud.rst +++ /dev/null @@ -1,126 +0,0 @@ -Alibaba Cloud Compute Services Guide -==================================== - -.. _alicloud_intro: - -Introduction -```````````` - -Ansible contains several modules for controlling and managing Alibaba Cloud Compute Services (Alicloud). The purpose of this -section is to explain how to put Ansible modules together to use Ansible in Alicloud context. - -All of the modules require footmark and it can be installed by python's "sudo pip install footmark" in your control machine. - -Classically, ansible will execute tasks in remote machines which defined in its hosts, most cloud-control steps occur on your local machine with reference to the regions to control. - -Normally, we'll use the following pattern for provisioning steps:: - - - hosts: localhost - connection: local - vars: - - ... - tasks: - - ... - -.. _alicloud_authentication: - -Authentication -`````````````` - -Authentication with the Alicloud-related modules is handled by either -specifying your access and secret key as ENV variables or module arguments. - -For environment variables:: - - export ALICLOUD_ACCESS_KEY='Alicloud123' - export ALICLOUD_SECRET_KEY='AlicloudSecret123' - -For storing these in a vars_file, ideally encrypted with `ansible-vault `_ considering its security:: - - --- - alicloud_access_key: "--REMOVED--" - alicloud_secret_key: "--REMOVED--" - -Note that if you store your credentials in vars_file, you need to refer to them in each Alicloud-module. For example:: - - - alicloud_instance: - alicloud_access_key: "{{alicloud_access_key}}" - alicloud_secret_key: "{{alicloud_secret_key}}" - image_id: "..." - -.. _alicloud_provisioning: - -Provisioning -```````````` - -There are a number of modules to create ECS instance, disk, VPC, VSwitch, Security Group and other resources. - -An example of making sure there are only 5 instances tagged 'NewECS' and other resources as Alicloud Module follows. - -In the example below, the ``count`` of instances is set to 5. This means if there are 0 instances already existing, then -5 new instances would be created. If there were 2 instances, only 3 would be created, and if there were 8 instances, -3 instances would be terminated. - -If ``count_tag`` is not specified, ``coun`` would use ``instance_name`` to create specified number of instances. - -:: - - # alicloud_setup.yml - - - hosts: localhost - connection: local - - tasks: - - - name: Create VPC - alicloud_vpc: - cidr_block: '{{ cidr_block }}' - vpc_name: new_vpc - register: created_vpc - - - name: Create VSwitch - alicloud_vswitch: - alicloud_zone: '{{ alicloud_zone }}' - cidr_block: '{{ vsw_cidr }}' - vswitch_name: new_vswitch - vpc_id: '{{ created_vpc.vpc_id }}' - register: created_vsw - - - name: Create security group - alicloud_security_group: - name: new_group - vpc_id: '{{ created_vpc.vpc_id }}' - rules: - - proto: tcp - port_range: 22/22 - cidr_ip: 0.0.0.0/0 - priority: 1 - rules_egress: - - proto: tcp - port_range: 80/80 - cidr_ip: 192.168.0.54/32 - priority: 1 - register: created_group - - - name: Create a set of instances - alicloud_instance: - group_id: '{{ created_group.group_id }}' - instance_type: ecs.n4.small - image_id: "{{ ami_id }}" - instance_name: "My-new-instance" - instance_tags: - Name: NewECS - Version: 0.0.1 - count: 5 - count_tag: - Name: NewECS - allocate_public_ip: true - max_bandwidth_out: 50 - vswitch_id: '{{ created_vsw.vswitch_id}}' - register: create_instance - -The data about what vpc, vswitch, instances and other resource are created are being saved by the "register" keyword in the corresponding variable. - -Each of the Alicloud modules offers a variety of parameter options. Not all options are demonstrated in the above example. -See each individual module for further details and examples. - diff --git a/galaxy.yml b/galaxy.yml new file mode 100644 index 00000000..956ee0d1 --- /dev/null +++ b/galaxy.yml @@ -0,0 +1,17 @@ +namespace: alibaba +name: alicloud +version: 1.0.0 +readme: README.md +authors: +- He Guimin (@xiaozhu36) +- Li Xue (@lixue323) +description: Alibaba alicloud +license: +- GPL-3.0-or-later +license_file: COPYING +tags: [] +dependencies: + ansible.netcommon: '>=0.0.1' +repository: https://github.com/alibaba/alibaba.alicloud.git +homepage: https://github.com/alibaba/alibaba.alicloud +issues: https://github.com/alibaba/alibaba.alicloud/issues diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md deleted file mode 100644 index 246b5b9e..00000000 --- a/lib/CHANGELOG.md +++ /dev/null @@ -1,42 +0,0 @@ -# Ansible-Alicloud-Module_Utils Change Log -## 1.6.0 (unreleased) - -## 1.5.0 (22 April, 2020) -IMPROVEMENTS: - - * alicloud_ecs.py: support ros ([#263](https://github.com/alibaba/ansible-provider/pull/263)) - * alicloud_ecs.py: support oos ([#259](https://github.com/alibaba/ansible-provider/pull/259)) - - -## 1.4.0 (1 March, 2020) - -IMPROVEMENTS: - - * alicloud_ecs.py: support market ([#240](https://github.com/alibaba/ansible-provider/pull/240)) - - -## 1.3.0 (11 December, 2019) - -IMPROVEMENTS: - - * alicloud_ecs.py: Support more authentication methods ([#209](https://github.com/alibaba/ansible-provider/pull/209)) - - -## 1.2.0 (unknown) - -## 1.1.0 (January 8, 2018) - -IMPROVEMENTS: - - * alicloud_ecs.py: supports ess ([#79](https://github.com/alibaba/footmark/pull/79)) - -## 1.0.8 (November 2, 2017) - -IMPROVEMENTS: - - * alicloud_ecs.py: remove redundant AK and region information([#67](https://github.com/alibaba/footmark/pull/67)) - -## 1.0.7(October 24, 2016) - - * **New Module:** `alicloud_ecs` - * **New Module:** `alicloud_oss` diff --git a/lib/MANIFEST.in b/lib/MANIFEST.in deleted file mode 100644 index 00da3fd6..00000000 --- a/lib/MANIFEST.in +++ /dev/null @@ -1,8 +0,0 @@ -prune ticket_stubs -prune hacking - -exclude ansible/setup.py -exclude ansible/__init__.py -exclude ansible/module_utils/__init__.py* -exclude *.egg-info -exclude ansible/dist diff --git a/lib/ansible/__init__.py b/lib/ansible/__init__.py deleted file mode 100644 index d8aeac5e..00000000 --- a/lib/ansible/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# (c) 2012-2014, Michael DeHaan -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -# Note: Do not add any code to this file. The ansible module may be -# a namespace package when using Ansible-2.1+ Anything in this file may not be -# available if one of the other packages in the namespace is loaded first. -# -# This is for backwards compat. Code should be ported to get these from -# ansible.release instead of from here. -from ansible.release import __version__, __author__ diff --git a/lib/ansible/galaxy/deploy/.travis.yml b/lib/ansible/galaxy/deploy/.travis.yml deleted file mode 100644 index c2063613..00000000 --- a/lib/ansible/galaxy/deploy/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -language: python -python: "3.6" - -# Use the new container infrastructure -sudo: false - -# Install ansible -addons: - apt: - packages: - - python-pip - -install: - # Install ansible - - pip install ansible - - # Check ansible version - - ansible --version - - # Create ansible.cfg with correct roles_path - - printf '[defaults]\nroles_path=../' >ansible.cfg - -script: - # Basic role syntax check - - ansible-playbook tests/test.yml -i tests/inventory --syntax-check - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/lib/ansible/galaxy/deploy/README.md b/lib/ansible/galaxy/deploy/README.md deleted file mode 100644 index 00e25549..00000000 --- a/lib/ansible/galaxy/deploy/README.md +++ /dev/null @@ -1,115 +0,0 @@ -Role Name -========= - -- You can use this role to deploy petstore on alicloud ecs, it supports set variable zone, and deploy on multiple instances. -- The version of python is 3.6 - -Requirements ------------- -Before you use this role, you must install below, like this 'pip install ansible-alicloud'': -- ansible-alicloud -- ansible_alicloud_module_utils - - -Role Variables --------------- - -#### ecs instance filter parameters - -exist: False -alicloud_path: ./ -instance_name: ['Instance_From_Ansible_Petstore', 'a-Instance_From_Ansible_Petstore'] -instance_tags: {For: PetStore, Created: Ansible, From: example/deploy} -image_id: "ubuntu_18_04_64_20G_alibase_20190624.vhd" -instance_type: ecs.sn2ne.large -instance_description: "Create a new ECS instance resource via Ansible example deploy-ecs." -host_name: "my-instance-from-ansible" -password: Test12345 - -allocate_public_ip: True -internet_charge_type: "PayByTraffic" -max_bandwidth_in: 200 -max_bandwidth_out: 50 - -system_disk_category: "cloud_ssd" -system_disk_size: 50 -number_of_instances: 2 - -#### security group filter parameters -security_group_name: 'Security_Group_From_Ansible' -security_group_tags: {For: PetStore, Created: Ansible, From: example/deploy} - -group_description: "Create a new security group resource via Ansible example deploy-ecs." -group_inboundRules: - - ip_protocol: tcp - port_range: 22/22 - source_cidr_ip: 0.0.0.0/0 - priority: 1 - - - ip_protocol: tcp - port_range: 80/80 - source_cidr_ip: 0.0.0.0/0 - priority: 1 - - - ip_protocol: tcp - port_range: 8081/8081 - source_cidr_ip: 0.0.0.0/0 - priority: 1 - -group_outboundRules: - - ip_protocol: tcp - port_range: 80/80 - dest_cidr_ip: 192.168.0.54/32 - priority: 1 - -#### vpc filter parameters -vpc_name: 'Vpc_From_Ansible' -vpc_tags: {For: PetStore, Created: Ansible, From: example/deploy} -vpc_cidr: "172.16.0.0/12" -vpc_description: "Create a new VPC resource via Ansible example-deploy-ecs." - -#### vswitch parameters -availability_zones: ["cn-beijing-e", "cn-beijing-f"] -vswitch_cidrs: ["172.16.1.0/24", "172.22.0.0/16"] -vswitch_description: "Create a new VSwitch resource via Ansible example-deploy-ecs." -vswitch_name: 'Vswitch_From_Ansible' - - -Example Playbook ----------------- -- Before you use this role, Execute the following command to download the latest version of alicloud dynamic inventory file - wget https://raw.githubusercontent.com/alibaba/ansible-provider/master/contrib/inventory/alicloud.py - chmod +x alicloud.py - wget https://raw.githubusercontent.com/alibaba/ansible-provider/master/contrib/inventory/alicloud.ini - -- Configure your authentication: - alicloud.ini - alicloud_access_key = Abcd1234 - alicloud_secret_key = Abcd2345 - - or - - environment variable - export ALICLOUD_ACCESS_KEY = Abcd1234 - export ALICLOUD_SECRET_KEY = Abcd2345 - -- Configure filter parameters in the INI file to filter out the target host - -#### Finally use role to deploy: - - - hosts: servers - roles: - - deploy - exist: False - alicloud_path: /tmp/alicloud.py - number_of_instances: 4 - -License -------- - -GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -Author Information ------------------- -- "He Guimin (@xiaozhu36)" -- "Li Xue (@lixue323)" \ No newline at end of file diff --git a/lib/ansible/galaxy/deploy/defaults/main.yml b/lib/ansible/galaxy/deploy/defaults/main.yml deleted file mode 100644 index 14d1a41a..00000000 --- a/lib/ansible/galaxy/deploy/defaults/main.yml +++ /dev/null @@ -1,59 +0,0 @@ ---- -exist: False -alicloud_path: ./ -# ecs instance filter parameters -instance_name: ['Instance_From_Ansible_Petstore', 'a-Instance_From_Ansible_Petstore'] -instance_tags: {For: PetStore, Created: Ansible, From: example/deploy} -image_id: "ubuntu_18_04_64_20G_alibase_20190624.vhd" -instance_type: ecs.sn2ne.large -instance_description: "Create a new ECS instance resource via Ansible example deploy-ecs." -host_name: "my-instance-from-ansible" -password: Test12345 - -allocate_public_ip: True -internet_charge_type: "PayByTraffic" -max_bandwidth_in: 200 -max_bandwidth_out: 50 - -system_disk_category: "cloud_ssd" -system_disk_size: 50 -number_of_instances: 2 - -# security group filter parameters -security_group_name: 'Security_Group_From_Ansible' -security_group_tags: {For: PetStore, Created: Ansible, From: example/deploy} - -group_description: "Create a new security group resource via Ansible example deploy-ecs." -group_inboundRules: - - ip_protocol: tcp - port_range: 22/22 - source_cidr_ip: 0.0.0.0/0 - priority: 1 - - - ip_protocol: tcp - port_range: 80/80 - source_cidr_ip: 0.0.0.0/0 - priority: 1 - - - ip_protocol: tcp - port_range: 8081/8081 - source_cidr_ip: 0.0.0.0/0 - priority: 1 - -group_outboundRules: - - ip_protocol: tcp - port_range: 80/80 - dest_cidr_ip: 192.168.0.54/32 - priority: 1 - -# vpc filter parameters -vpc_name: 'Vpc_From_Ansible' -vpc_tags: {For: PetStore, Created: Ansible, From: example/deploy} -vpc_cidr: "172.16.0.0/12" -vpc_description: "Create a new VPC resource via Ansible example-deploy-ecs." - -# vswitch parameters -availability_zones: ["cn-beijing-e", "cn-beijing-f"] -vswitch_cidrs: ["172.16.1.0/24", "172.22.0.0/16"] -vswitch_description: "Create a new VSwitch resource via Ansible example-deploy-ecs." -vswitch_name: 'Vswitch_From_Ansible' \ No newline at end of file diff --git a/lib/ansible/galaxy/deploy/meta/main.yml b/lib/ansible/galaxy/deploy/meta/main.yml deleted file mode 100644 index a4545704..00000000 --- a/lib/ansible/galaxy/deploy/meta/main.yml +++ /dev/null @@ -1,20 +0,0 @@ -galaxy_info: - author: - - "He Guimin (@xiaozhu36)" - - "Li Xue (@lixue323)" - - description: Deploy Petstore on ecs instance. - - company: - - license: license (GPL-2.0-or-later, MIT, etc) - - min_ansible_version: 2.9 - - galaxy_tags: - - petstore - - ecs - - alicloud - - vpc - -dependencies: [] diff --git a/lib/ansible/galaxy/deploy/tasks/create.yml b/lib/ansible/galaxy/deploy/tasks/create.yml deleted file mode 100644 index b606c6db..00000000 --- a/lib/ansible/galaxy/deploy/tasks/create.yml +++ /dev/null @@ -1,78 +0,0 @@ ---- -- name: Create a new alicloud VPC resource - ali_vpc: - cidr_block: '{{ vpc_cidr }}' - vpc_name: '{{ vpc_name }}' - description: '{{ vpc_description }}' - register: vpc - -- name: Get the existing vpc - ali_vpc_info: - name_prefix: '{{vpc_name}}' - register: vpcs - -- name: Create a new alicloud VSwitch resource - ali_vswitch: - alicloud_zone: '{{ item.0 }}' - cidr_block: '{{ item.1 }}' - vswitch_name: '{{ vswitch_name }}' - description: '{{ vswitch_description }}' - vpc_id: '{{vpc.vpc.id}}' - with_together: - - '{{ availability_zones }}' - - '{{ vswitch_cidrs }}' - -- name: Get the existing vswitch - ali_vswitch_info: - name_prefix: '{{ vswitch_name }}' - filters: - vpc_id: '{{vpc.vpc.id}}' - register: vswitches - - -- name: Create a VPC security group - ali_security_group: - name: '{{ security_group_name }}' - description: '{{ group_description }}' - vpc_id: '{{vpc.vpc.id}}' - rules: '{{ group_inboundRules }}' - rules_egress: '{{ group_outboundRules }}' - register: group - -- name: Get the existing groups - ali_security_group_info: - name_prefix: '{{ security_group_name }}' - register: sgs - - -- name: Get the existing ECS instances - ali_instance_info: - name_prefix: '{{ instance_name }}' - filters: - vpc_id: '{{ vpcs.vpcs.0.id }}' - register: instances - -- name: Creating two ECS instances - ali_instance: - image: '{{ image_id }}' - type: '{{ instance_type }}' - instance_name: '{{ item.1 }}' - description: '{{ instance_description }}' - host_name: '{{ host_name }}' - password: '{{ password }}' - - allocate_public_ip: '{{ allocate_public_ip }}' - internet_charge_type: '{{ internet_charge_type }}' - max_bandwidth_in: '{{ max_bandwidth_in }}' - max_bandwidth_out: '{{ max_bandwidth_out }}' - - security_groups: ['{{ sgs.groups.0.id }}'] - vswitch_id: '{{ item.0.id }}' - - system_disk_category: '{{ system_disk_category }}' - system_disk_size: '{{ system_disk_size }}' - count: '{{ number_of_instances }}' - tags: '{{ instance_tags }}' - with_together: - - '{{ vswitches.vswitches }}' - - '{{ instance_name }}' \ No newline at end of file diff --git a/lib/ansible/galaxy/deploy/tasks/deploy.yml b/lib/ansible/galaxy/deploy/tasks/deploy.yml deleted file mode 100644 index ef131ac3..00000000 --- a/lib/ansible/galaxy/deploy/tasks/deploy.yml +++ /dev/null @@ -1,58 +0,0 @@ ---- -- name: Deploy petstore on ECS - hosts: alicloud - remote_user: root - - tasks: - - name: create property file - shell: "{{item}}" - with_items: - - echo "petstore.loggingLevel = warn" >> /root/antx.properties - - echo "petstore.loggingRoot = /root/pet/logs" >> /root/antx.properties - - echo "petstore.upload = /root/pet/upload" >> /root/antx.properties - - echo "petstore.work = /root/pet" >> /root/antx.properties - - - name: remove java11 - apt: - pkg: - - openjdk-11-jre-headless - - openjdk-11-jdk - state: absent - force_apt_get: True - - - name: build enviroment - apt: - pkg: - - apache2 - - openjdk-8-jre-headless - - openjdk-8-jdk - - git - - maven - force_apt_get: True - - - name: clone project - command: "{{item}}" - with_items: - - git clone https://github.com/webx/citrus-sample.git - ignore_errors: True - - - name: mvn install - command: "{{item}}" - args: - chdir: /root/citrus-sample/petstore - with_items: - - mvn clean install - ignore_errors: True - async: 600 - poll: 10 - - - name: run project - shell: - cmd: nohup mvn jetty:run-war & - chdir: /root/citrus-sample/petstore/web - register: petstore - - - wait_for: port=8081 state=started - - - debug: - msg: http://{{hostvars[inventory_hostname]['public_ip_address']}}:8081?home diff --git a/lib/ansible/galaxy/deploy/tasks/main.yml b/lib/ansible/galaxy/deploy/tasks/main.yml deleted file mode 100644 index 46220712..00000000 --- a/lib/ansible/galaxy/deploy/tasks/main.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -# tasks file for deploy -- include_tasks: create.yml - when: not exist -- name: excute inventory file to get target host - shell: ./{{ alicloud_path }} --list -- include_tasks: deploy.yml diff --git a/lib/ansible/galaxy/deploy/tests/test.yml b/lib/ansible/galaxy/deploy/tests/test.yml deleted file mode 100644 index bb79681e..00000000 --- a/lib/ansible/galaxy/deploy/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - deploy \ No newline at end of file diff --git a/lib/ansible/galaxy/market/.travis.yml b/lib/ansible/galaxy/market/.travis.yml deleted file mode 100644 index c2063613..00000000 --- a/lib/ansible/galaxy/market/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -language: python -python: "3.6" - -# Use the new container infrastructure -sudo: false - -# Install ansible -addons: - apt: - packages: - - python-pip - -install: - # Install ansible - - pip install ansible - - # Check ansible version - - ansible --version - - # Create ansible.cfg with correct roles_path - - printf '[defaults]\nroles_path=../' >ansible.cfg - -script: - # Basic role syntax check - - ansible-playbook tests/test.yml -i tests/inventory --syntax-check - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/lib/ansible/galaxy/market/README.md b/lib/ansible/galaxy/market/README.md deleted file mode 100644 index cb95a418..00000000 --- a/lib/ansible/galaxy/market/README.md +++ /dev/null @@ -1,100 +0,0 @@ -Role Name -========= - -- Search market product and use image to create ecs -- The version of python is 3.6 - -Requirements ------------- - -Before you use this role, you must install below, like this 'pip install ansible-alicloud'': -- ansible-alicloud - -Role Variables --------------- -alicloud_region: cn-beijing - -#### market product info -product_keyword: Wordpress -product_supplier_name_keyword: '' -product_suggested_price: 0 -product_name_prefix: '' -product_type: "" -product_sort: '' -product_category_id: '' -product_ids: '' -product_supplier_id: '' - -#### ecs instance filter parameters -instance_name: ['Instance_From_Ansible_Market', 'a-Instance_From_Ansible_Market'] -instance_tags: {For: Market, Created: Ansible, From: example/market} -image_id: "ubuntu_18_04_64_20G_alibase_20190624.vhd" -instance_type: ecs.g5.large -instance_description: "Create a new ECS instance resource via Ansible example market." -password: YourPassword123 - -allocate_public_ip: True -internet_charge_type: "PayByTraffic" -max_bandwidth_in: 200 -max_bandwidth_out: 50 - -system_disk_category: "cloud_ssd" -system_disk_size: 50 -number_of_instances: 1 - -#### security group filter parameters -security_group_name: 'Security_Group_From_Ansible_Market' -security_group_tags: {For: Market, Created: Ansible, From: example/market} - -group_description: "Create a new security group resource via Ansible example market." -group_inboundRules: - - ip_protocol: tcp - port_range: 22/22 - source_cidr_ip: 0.0.0.0/0 - priority: 1 - - - ip_protocol: tcp - port_range: 80/80 - source_cidr_ip: 0.0.0.0/0 - priority: 1 - -group_outboundRules: - - ip_protocol: tcp - port_range: 80/80 - dest_cidr_ip: 192.168.0.54/32 - priority: 1 - -#### vpc filter parameters -vpc_name: 'Vpc_From_Ansible_Market' -vpc_tags: {For: Market, Created: Ansible, From: example/market} -vpc_cidr: "172.16.0.0/12" -vpc_description: "Create a new VPC resource via Ansible example market." - -#### vswitch parameters -availability_zones: ["cn-beijing-e", "cn-beijing-f"] -vswitch_cidr: ["172.16.1.0/24", "172.22.0.0/16"] -vswitch_description: "Create a new VSwitch resource via Ansible example market." -vswitch_name: 'Vswitch_From_Ansible_Market' - - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers - roles: - - market - product_keyword: 'Wordpress' - password: MyPassword - number_of_instances: 2 - -License -------- - -GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -Author Information ------------------- -- "He Guimin (@xiaozhu36)" -- "Li Xue (@lixue323)" \ No newline at end of file diff --git a/lib/ansible/galaxy/market/defaults/main.yml b/lib/ansible/galaxy/market/defaults/main.yml deleted file mode 100644 index 922fdd1c..00000000 --- a/lib/ansible/galaxy/market/defaults/main.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- -alicloud_region: cn-beijing - -# market product info -product_keyword: Wordpress -product_supplier_name_keyword: '' -product_suggested_price: 0 -product_name_prefix: '' -product_category_id: '' -product_ids: '' -product_supplier_id: '' - -# ecs instance filter parameters -instance_name: ['Instance_From_Market', 'a-Instance_From_Market'] -instance_tags: {For: Market, Created: Ansible, From: role/market} -image_id: "ubuntu_18_04_64_20G_alibase_20190624.vhd" -instance_type: ecs.sn2ne.large -instance_description: "Create a new ECS instance resource via role market." -host_name: "my-instance-from-ansible" -password: Test12345 - -allocate_public_ip: True -internet_charge_type: "PayByTraffic" -max_bandwidth_in: 200 -max_bandwidth_out: 50 - -system_disk_category: "cloud_ssd" -system_disk_size: 50 -number_of_instances: 2 - -# security group filter parameters -security_group_name: 'Security_Group_From_Ansible_Market' -security_group_tags: {For: Market, Created: Ansible, From: example/market} - -group_description: "Create a new security group resource via Ansible example market." -group_inboundRules: - - ip_protocol: tcp - port_range: 22/22 - source_cidr_ip: 0.0.0.0/0 - priority: 1 - - - ip_protocol: tcp - port_range: 80/80 - source_cidr_ip: 0.0.0.0/0 - priority: 1 - -group_outboundRules: - - ip_protocol: tcp - port_range: 80/80 - dest_cidr_ip: 192.168.0.54/32 - priority: 1 - -# vpc filter parameters -vpc_name: 'Vpc_From_Ansible_Market' -vpc_tags: {For: Market, Created: Ansible, From: example/market} -vpc_cidr: "172.16.0.0/12" -vpc_description: "Create a new VPC resource via Ansible example market." - -# vswitch parameters -availability_zones: ["cn-beijing-e", "cn-beijing-f"] -vswitch_cidr: ["172.16.1.0/24", "172.22.0.0/16"] -vswitch_description: "Create a new VSwitch resource via Ansible example market." -vswitch_name: 'Vswitch_From_Ansible_Market' - diff --git a/lib/ansible/galaxy/market/meta/main.yml b/lib/ansible/galaxy/market/meta/main.yml deleted file mode 100644 index 49b2bae6..00000000 --- a/lib/ansible/galaxy/market/meta/main.yml +++ /dev/null @@ -1,19 +0,0 @@ -galaxy_info: - author: - - "He Guimin (@xiaozhu36)" - - "Li Xue (@lixue323)" - description: Search market product and use image to create ecs - - company: ???? - - license: license (GPL-2.0-or-later, MIT, etc) - - min_ansible_version: 2.9 - - galaxy_tags: - - alicloud_market - - image - - alicloud - - ecs - -dependencies: [] diff --git a/lib/ansible/galaxy/market/tasks/create.yml b/lib/ansible/galaxy/market/tasks/create.yml deleted file mode 100644 index f43c1a9a..00000000 --- a/lib/ansible/galaxy/market/tasks/create.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -- name: Search products - ali_market_product_info: - alicloud_region: '{{ alicloud_region }}' - search_term: '{{ product_keyword }}' - supplier_name_keyword: '{{ product_supplier_name_keyword }}' - product_type: MIRROR - category_id: '{{ product_category_id }}' - suggested_price: '{{ product_suggested_price }}' - name_prefix: '{{ product_name_prefix }}' - ids: '{{ product_ids }}' - supplier_id: '{{ product_supplier_id }}' - register: products - -- name: Get the existing ECS instances - ali_instance_info: - alicloud_region: '{{ alicloud_region }}' - name_prefix: '{{ instance_name }}' - filters: - page_size: 100 - register: instances - -- name: Creating two ECS instances - ali_instance: - image: '{{ products.products.0.image_ids.0.value }}' - type: '{{ instance_type }}' - instance_name: '{{ item.1 }}' - description: '{{ instance_description }}' - host_name: '{{ host_name }}' - password: '{{ password }}' - - allocate_public_ip: '{{ allocate_public_ip }}' - internet_charge_type: '{{ internet_charge_type }}' - max_bandwidth_in: '{{ max_bandwidth_in }}' - max_bandwidth_out: '{{ max_bandwidth_out }}' - - security_groups: ['{{ sgs.groups.0.id }}'] - vswitch_id: '{{ item.0.id }}' - - system_disk_category: '{{ system_disk_category }}' - system_disk_size: '{{ system_disk_size }}' - count: '{{ number_of_instances }}' - tags: '{{ instance_tags }}' - with_together: - - '{{ vswitches.vswitches }}' - - '{{ instance_name }}' - register: all_instances - when: not instances.instances - -- debug: - msg: http://{{ item.instances.0.public_ip_address }} - with_items: '{{ all_instances }}' \ No newline at end of file diff --git a/lib/ansible/galaxy/market/tasks/main.yml b/lib/ansible/galaxy/market/tasks/main.yml deleted file mode 100644 index 148cdc69..00000000 --- a/lib/ansible/galaxy/market/tasks/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# tasks file for market -- include_tasks: vpc.yml -- include_tasks: vswitch.yml -- include_tasks: security.yml -- include_tasks: create.yml diff --git a/lib/ansible/galaxy/market/tasks/security.yml b/lib/ansible/galaxy/market/tasks/security.yml deleted file mode 100644 index 2a682e93..00000000 --- a/lib/ansible/galaxy/market/tasks/security.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: Create a VPC security group - ali_security_group: - alicloud_region: '{{ alicloud_region }}' - name: '{{ security_group_name }}' - description: '{{ group_description }}' - vpc_id: '{{vpc.vpc.id}}' - rules: '{{ group_inboundRules }}' - rules_egress: '{{ group_outboundRules }}' - register: group - -- name: Get the existing groups - ali_security_group_info: - alicloud_region: '{{ alicloud_region }}' - name_prefix: '{{ security_group_name }}' - register: sgs diff --git a/lib/ansible/galaxy/market/tasks/vpc.yml b/lib/ansible/galaxy/market/tasks/vpc.yml deleted file mode 100644 index a1179583..00000000 --- a/lib/ansible/galaxy/market/tasks/vpc.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: Create a new alicloud VPC resource - ali_vpc: - alicloud_region: '{{ alicloud_region }}' - cidr_block: '{{ vpc_cidr }}' - vpc_name: '{{ vpc_name }}' - description: '{{ vpc_description }}' - register: vpc - -- name: Get the existing vpc - ali_vpc_info: - alicloud_region: '{{ alicloud_region }}' - name_prefix: '{{vpc_name}}' - register: vpcs \ No newline at end of file diff --git a/lib/ansible/galaxy/market/tasks/vswitch.yml b/lib/ansible/galaxy/market/tasks/vswitch.yml deleted file mode 100644 index 2ef1af35..00000000 --- a/lib/ansible/galaxy/market/tasks/vswitch.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- name: Create a new alicloud VSwitch resource - ali_vswitch: - alicloud_zone: '{{ item.0 }}' - cidr_block: '{{ item.1 }}' - vswitch_name: '{{ vswitch_name }}' - description: '{{ vswitch_description }}' - vpc_id: '{{vpc.vpc.id}}' - with_together: - - '{{ availability_zones }}' - - '{{ vswitch_cidr }}' - -- name: Get the existing vswitch - ali_vswitch_info: - name_prefix: '{{ vswitch_name }}' - filters: - vpc_id: '{{vpc.vpc.id}}' - register: vswitches \ No newline at end of file diff --git a/lib/ansible/galaxy/market/tests/inventory b/lib/ansible/galaxy/market/tests/inventory deleted file mode 100644 index 878877b0..00000000 --- a/lib/ansible/galaxy/market/tests/inventory +++ /dev/null @@ -1,2 +0,0 @@ -localhost - diff --git a/lib/ansible/galaxy/market/tests/test.yml b/lib/ansible/galaxy/market/tests/test.yml deleted file mode 100644 index f733fb03..00000000 --- a/lib/ansible/galaxy/market/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - market \ No newline at end of file diff --git a/lib/ansible/galaxy/tags/.travis.yml b/lib/ansible/galaxy/tags/.travis.yml deleted file mode 100644 index c2063613..00000000 --- a/lib/ansible/galaxy/tags/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -language: python -python: "3.6" - -# Use the new container infrastructure -sudo: false - -# Install ansible -addons: - apt: - packages: - - python-pip - -install: - # Install ansible - - pip install ansible - - # Check ansible version - - ansible --version - - # Create ansible.cfg with correct roles_path - - printf '[defaults]\nroles_path=../' >ansible.cfg - -script: - # Basic role syntax check - - ansible-playbook tests/test.yml -i tests/inventory --syntax-check - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/lib/ansible/galaxy/tags/README.md b/lib/ansible/galaxy/tags/README.md deleted file mode 100644 index 6cffd5cd..00000000 --- a/lib/ansible/galaxy/tags/README.md +++ /dev/null @@ -1,68 +0,0 @@ -Role Name -========= - -filter resources and add tags for them. -- ECS -- VPC -- Vswitch -- Security_Group - -The version of python is 3.6 - -Requirements ------------- - -Before you use this role, you must install below, like this 'pip install ansible-alicloud'': -- ansible-alicloud - -Role Variables --------------- - -state: present -alicloud_region: "cn-hangzhou" - -#### default tags -tags: {env: prod, source: ansible, usage: poc} - -#### ecs instance filter parameters and tags -instance_name: '' -instance_filters: {} -instance_tags: {} - -#### security group filter parameters and tags -security_group_name: '' -security_group_filters: {} -security_group_tags: {} - -#### vpc filter parameters and tags -vpc_name: '' -vpc_filters: {} -vpc_tags: {} - -#### vswitch filter parameters and tags -vswitch_name: "" -vswitch_filters: {} -vswitch_tags: {} - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers - roles: - - tags: - instance_name: 'Ansible_Instance' - instance_tags: {For: Ansible} - state: absent - - -License -------- - -GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -Author Information ------------------- -- "He Guimin (@xiaozhu36)" -- "Li Xue (@lixue323)" \ No newline at end of file diff --git a/lib/ansible/galaxy/tags/defaults/main.yml b/lib/ansible/galaxy/tags/defaults/main.yml deleted file mode 100644 index ef70202f..00000000 --- a/lib/ansible/galaxy/tags/defaults/main.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -state: present -alicloud_region: "cn-hangzhou" - -# default tags -tags: {env: prod, source: ansible, usage: poc} - -# ecs instance filter parameters and tags -instance_name: '' -instance_filters: {} -instance_tags: {} - -# security group filter parameters and tags -security_group_name: '' -security_group_filters: {} -security_group_tags: {} - -# vpc filter parameters and tags -vpc_name: '' -vpc_filters: {} -vpc_tags: {} - -# vswitch filter parameters and tags -vswitch_name: "" -vswitch_filters: {} -vswitch_tags: {} \ No newline at end of file diff --git a/lib/ansible/galaxy/tags/handlers/main.yml b/lib/ansible/galaxy/tags/handlers/main.yml deleted file mode 100644 index 52441a3e..00000000 --- a/lib/ansible/galaxy/tags/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# handlers file for tags \ No newline at end of file diff --git a/lib/ansible/galaxy/tags/meta/main.yml b/lib/ansible/galaxy/tags/meta/main.yml deleted file mode 100644 index e952e92f..00000000 --- a/lib/ansible/galaxy/tags/meta/main.yml +++ /dev/null @@ -1,21 +0,0 @@ -galaxy_info: - author: - - "He Guimin (@xiaozhu36)" - - "Li Xue (@lixue323)" - description: Batch operate tags to existing alicloud vpc product, The resources currently supported are as follows - - VPC - - Vswitch - - Elastic IP Address - - company: ???? - - license: license (GPL-2.0-or-later, MIT, etc) - - min_ansible_version: 2.9 - - galaxy_tags: - - alicloud - - tags - - vpc - -dependencies: [] diff --git a/lib/ansible/galaxy/tags/tasks/main.yml b/lib/ansible/galaxy/tags/tasks/main.yml deleted file mode 100644 index 89e1e190..00000000 --- a/lib/ansible/galaxy/tags/tasks/main.yml +++ /dev/null @@ -1,75 +0,0 @@ ---- -- name: Filter instance using name_regex - ali_instance_info: - alicloud_region: '{{ alicloud_region }}' - name_prefix: '{{ instance_name }}' - filters: '{{ instance_filters }}' - register: instances - when: instance_tags - -- name: Changed. Operation instance tags. - ali_ecs_tag: - alicloud_region: '{{ alicloud_region }}' - state: '{{ state }}' - resource_type: 'instance' - resource_ids: '{{ instances.ids }}' - tags: '{{ instance_tags }}' - when: instance_tags and instances.ids - - -- name: Filter security group using name_regex - ali_security_group_info: - alicloud_region: '{{ alicloud_region }}' - name_prefix: '{{ security_group_name }}' - filters: '{{ security_group_filters }}' - register: sgs - when: security_group_tags - - -- name: Changed. Operation security group Tags. - ali_ecs_tag: - alicloud_region: '{{ alicloud_region }}' - state: '{{ state }}' - resource_type: 'securitygroup' - resource_ids: '{{ sgs.ids }}' - tags: '{{ security_group_tags }}' - when: security_group_tags and sgs.ids - - -- name: Filter vpc using name_regex - ali_vpc_info: - alicloud_region: '{{ alicloud_region }}' - name_prefix: '{{ vpc_name }}' - filters: '{{ vpc_filters }}' - register: vpcs - when: vpc_tags - - -- name: Changed. Operation vpc tags. - ali_vpc_tag: - alicloud_region: '{{ alicloud_region }}' - state: '{{ state }}' - resource_type: 'vpc' - resource_ids: '{{ vpcs.ids }}' - tags: '{{ vpc_tags }}' - when: vpc_tags and vpcs.ids - - -- name: Filter the existing vswitch - ali_vswitch_info: - alicloud_region: '{{ alicloud_region }}' - name_prefix: '{{ vswitch_name }}' - filters: '{{ vswitch_filters }}' - register: vswithes - when: vswitch_tags - - -- name: Changed. Operation vswitch Tags. - ali_vpc_tag: - alicloud_region: '{{ alicloud_region }}' - state: '{{ state }}' - resource_type: 'vswitch' - resource_ids: '{{ vswithes.ids }}' - tags: '{{ vswitch_tags }}' - when: vswitch_tags and vswithes.ids - diff --git a/lib/ansible/galaxy/tags/tests/inventory b/lib/ansible/galaxy/tags/tests/inventory deleted file mode 100644 index 878877b0..00000000 --- a/lib/ansible/galaxy/tags/tests/inventory +++ /dev/null @@ -1,2 +0,0 @@ -localhost - diff --git a/lib/ansible/galaxy/tags/tests/test.yml b/lib/ansible/galaxy/tags/tests/test.yml deleted file mode 100644 index 8b300309..00000000 --- a/lib/ansible/galaxy/tags/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - tags \ No newline at end of file diff --git a/lib/ansible/module_utils/__init__.py b/lib/ansible/module_utils/__init__.py deleted file mode 100644 index 9cde27b5..00000000 --- a/lib/ansible/module_utils/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# 2013, Michael DeHaan -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Note: Do not add any code to this file. module_utils may be a namespace -# package when using Ansible-2.1+ Anything in this file may not be available -# if one of the other packages in the namespace is loaded first. diff --git a/lib/ansible/modules/cloud/__init__.py b/lib/ansible/modules/cloud/__init__.py deleted file mode 100644 index 9fbc5507..00000000 --- a/lib/ansible/modules/cloud/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# __init__.py -__version__ = "1.0.4" diff --git a/lib/ansible/modules/cloud/alicloud/_ali_disk_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_disk_facts.py deleted file mode 100644 index f1734817..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_disk_facts.py +++ /dev/null @@ -1,255 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_disk_facts -version_added: "1.5.0" -short_description: Gather facts on disks of Alibaba Cloud ECS. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the ECS disk itself. - -options: - alicloud_zone: - description: - - Aliyun availability zone ID in which to launch the disk - aliases: ['zone_id', 'zone' ] - disk_names: - description: - - A list of ECS disk names. - aliases: [ "names"] - disk_ids: - description: - - A list of ECS disk ids. - aliases: ["ids"] -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Fetch disk details according to setting different filters -- name: fetch disk details example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-a - - tasks: - - name: Find all disks in the specified region - ali_disk_facts: - alicloud_zone: "{{ alicloud_zone }}" - alicloud_region: "{{ alicloud_region }}" - register: all_disks - - name: Find all disks based on the specified ids - ali_disk_facts: - alicloud_zone: "{{ alicloud_zone }}" - alicloud_region: "{{ alicloud_region }}" - disk_ids: - - "d-2ze8ohezcyvm4omrabud" - - "d-2zeakwizkdjdu4q4lfco" - register: disks_by_ids - - name: Find all disks based on the specified names/name-prefixes - ali_disk_facts: - alicloud_zone: "{{ alicloud_zone }}" - alicloud_region: "{{ alicloud_region }}" - disk_ids: - - "d-2ze8ohezcyvm4omrabud" - - "d-2zeakwizkdjdu4q4lfco" - disk_names: - - "test1" - register: disks_by_names - -''' - -RETURN = ''' -disk_ids: - description: List all disk's id after operating ecs disk. - returned: when success - type: list - sample: ["d-2ze8ohezcyvm4omrabud","d-2zeakwizkdjdu4q4lfco"] -disks: - description: Details about the ecs disks that were created. - returned: when success - type: list - sample: [ - { - "attached_time": "2017-08-15T06:47:55Z", - "category": "cloud_efficiency", - "creation_time": "2017-08-15T06:47:45Z", - "delete_auto_snapshot": false, - "delete_with_instance": true, - "description": "helloworld", - "detached_time": "", - "device": "/dev/xvda", - "disk_charge_type": "PostPaid", - "enable_auto_snapshot": true, - "encrypted": false, - "id": "d-2ze8ohezcyvm4omrabud", - "image_id": "ubuntu_140405_32_40G_cloudinit_20161115.vhd", - "instance_id": "i-2zegc3s8ihxq2pcysekk", - "name": "test1", - "operation_locks": { - "operation_lock": [] - }, - "portable": false, - "product_code": "", - "region_id": "cn-beijing", - "size": 40, - "snapshop_id": "", - "status": "in_use", - "type": "system", - "zone_id": "cn-beijing-a" - }, - { - "attached_time": "2017-08-13T06:57:37Z", - "category": "cloud_efficiency", - "creation_time": "2017-08-13T06:57:30Z", - "delete_auto_snapshot": false, - "delete_with_instance": true, - "description": "", - "detached_time": "", - "device": "/dev/xvda", - "disk_charge_type": "PostPaid", - "enable_auto_snapshot": true, - "encrypted": false, - "id": "d-2zeakwizkdjdu4q4lfco", - "image_id": "ubuntu_140405_64_40G_cloudinit_20161115.vhd", - "instance_id": "i-2zeenj8meljkoi85lz3c", - "name": "test2", - "operation_locks": { - "operation_lock": [] - }, - "portable": false, - "product_code": "", - "region_id": "cn-beijing", - "size": 40, - "snapshop_id": "", - "status": "in_use", - "type": "system", - "zone_id": "cn-beijing-a" - } -] -total: - description: The number of all disks after operating ecs disk. - returned: when success - type: int - sample: 2 -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, ecs_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_disk_info(disk): - """ - Retrieves disk information from an disk - ID and returns it as a dictionary - """ - return { - 'id': disk.id, - 'region_id': disk.region_id, - 'zone_id': disk.zone_id, - 'status': disk.status, - 'name': disk.disk_name, - 'description': disk.description, - 'type': disk.type, - 'category': disk.category, - 'encrypted': disk.encrypted, - 'size': disk.size, - 'image_id': disk.image_id, - 'snapshop_id': disk.source_snapshot_id, - 'product_code': disk.product_code, - 'portable': disk.portable, - 'operation_locks': disk.operation_locks, - 'instance_id': disk.instance_id, - "device": disk.device, - "delete_with_instance": disk.delete_with_instance, - "delete_auto_snapshot": disk.delete_auto_snapshot, - "enable_auto_snapshot": disk.enable_auto_snapshot, - "creation_time": disk.creation_time, - "attached_time": disk.attached_time, - "detached_time": disk.detached_time, - "disk_charge_type": disk.disk_charge_type, - } - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - alicloud_zone=dict(aliases=['zone_id', 'zone']), - disk_ids=dict(type='list', aliases=['ids']), - disk_names=dict(type='list', aliases=['names']), - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for this module') - - ecs = ecs_connect(module) - - disks = [] - disk_ids = [] - ids = module.params['disk_ids'] - names = module.params['disk_names'] - zone_id = module.params['alicloud_zone'] - if ids and (not isinstance(ids, list) or len(ids)) < 1: - module.fail_json(msg='disk_ids should be a list of disk id, aborting') - - if names and (not isinstance(names, list) or len(names)) < 1: - module.fail_json(msg='disk_names should be a list of disk name, aborting') - - if names: - for name in names: - for disk in ecs.get_all_volumes(zone_id=zone_id, volume_ids=ids, volume_name=name): - disks.append(get_disk_info(disk)) - disk_ids.append(disk.id) - else: - for disk in ecs.get_all_volumes(zone_id=zone_id, volume_ids=ids): - disks.append(get_disk_info(disk)) - disk_ids.append(disk.id) - - module.exit_json(changed=False, disk_ids=disk_ids, disks=disks, total=len(disks)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_eip_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_eip_facts.py deleted file mode 100644 index c1216375..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_eip_facts.py +++ /dev/null @@ -1,231 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_eip_facts -version_added: "2.8" -short_description: Gather facts about Elastic IP addresses in Alibaba Cloud -description: - - Gather facts about Elastic IP addresses in Alibaba Cloud -options: - eip_ids: - description: - - A list of EIP IDs that exist in your account. - aliases: ['ids'] - name_prefix: - description: - - Use a name prefix to filter EIPs. - ip_address_prefix: - description: - - Use a ip address prefix to filter EIPs. - aliases: ['ip_prefix'] - filters: - description: - - A dict of filters to apply. Each dict item consists of a filter key and a filter value. The filter keys can be - all of request parameters. See U(https://www.alibabacloud.com/help/doc-detail/36018.htm) for parameter details. - Filter keys can be same as request parameter name or be lower case and use underscore ("_") or dashes ("-") to - connect different words in one parameter. 'AllocationId' will be appended to I(eip_ids) automatically. -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.9.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Note: These examples do not set authentication details, see the Alibaba Cloud Guide for details. - -# Gather facts about all EIPs -- ali_eip_facts: - -# Gather facts about a particular EIP -- ali_eip_facts: - eip_ids: - - eip-xxxxxxx - - eip-yyyyyyy - filters: - status: Available - -# Gather facts about a particular EIP -- ali_eip_facts: - filters: - associated_instance_type: EcsInstance - -# Gather facts based on ip_address_prefix -- ali_eip_facts: - ip_address_prefix: 72.16 -''' - -RETURN = ''' -eips: - description: List of matching elastic ip addresses - returned: always - type: complex - contains: - allocation_id: - description: The EIP id - returned: always - type: string - sample: "eip-2zee1nu68juox4" - allocation_time: - description: The time the EIP was created - returned: always - type: string - sample: "2018-12-31T12:12:52Z" - bandwidth: - description: Maximum bandwidth from the internet network - returned: always - type: int - sample: 5 - charge_type: - description: The eip charge type. - returned: always - type: string - sample: "PostPaid" - description: - description: interface description - returned: always - type: string - sample: "My new EIP" - id: - description: Allocated EIP id (alias for allocation_id) - returned: always - type: string - sample: "eip-2zee1nu68juox4" - instance_id: - description: Associated instance id - returned: always - type: string - sample: "i-123456" - instance_region_id: - description: The region id in which the associated instance - returned: always - type: string - sample: "cn-beijing" - instance_type: - description: Associated instance type - returned: always - type: string - sample: "EcsInstance" - internet_charge_type: - description: The EIP charge type. - returned: always - type: string - sample: "PayByTraffic" - ip_address: - description: The IP address of the EIP - returned: always - type: string - sample: "39.96.169.143" - name: - description: The EIP name - returned: always - type: string - sample: "from-ansible" - status: - description: The EIP status - returned: always - type: string - sample: "inuse" - tags: - description: Any tags assigned to the EIP. - returned: always - type: dict - sample: {} -ids: - description: List of elastic ip address IDs - returned: always - type: list - sample: [eip-12345er, eip-3245fs] -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update( - dict( - eip_ids=dict(type='list', aliases=['ids']), - name_prefix=dict(), - ip_address_prefix=dict(type='str', aliases=['ip_prefix']), - filters=dict(type='dict'), - ) - ) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module ali_eip_facts') - - eips = [] - ids = [] - eip_ids = module.params["eip_ids"] - if not eip_ids: - eip_ids = [] - filters = module.params["filters"] - if not filters: - filters = {} - new_filters = {} - for key, value in list(filters.items()): - if str(key).lower().replace("-").replace("_") == "allocationid" and value not in eip_ids: - eip_ids.append(value) - continue - new_filters[key] = value - - name_prefix = module.params["name_prefix"] - address_prefix = module.params["ip_address_prefix"] - - try: - for eip in vpc_connect(module).describe_eip_addresses(**new_filters): - if name_prefix and not str(eip.name).startswith(name_prefix): - continue - if address_prefix and not str(eip.IpAddress).startswith(address_prefix): - continue - if eip_ids and eip.allocation_id not in eip_ids: - continue - eips.append(eip.read()) - ids.append(eip.id) - - module.exit_json(changed=False, ids=ids, eips=eips) - except Exception as e: - module.fail_json(msg=str("Unable to get eips, error:{0}".format(e))) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_eni_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_eni_facts.py deleted file mode 100644 index a16fa334..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_eni_facts.py +++ /dev/null @@ -1,232 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_eni_facts -short_description: Gather facts about ENI interfaces in Alibaba Cloud -description: - - Gather facts about ENI interfaces in Alibaba Cloud -version_added: "2.8.0" -options: - eni_ids: - description: - - A list of ENI IDs that exist in your account. - aliases: ['ids'] - name_prefix: - description: - - Use a name prefix to filter network interfaces. - tags: - description: - - A hash/dictionaries of network interface tags. C({"key":"value"}) - filters: - description: - - A dict of filters to apply. Each dict item consists of a filter key and a filter value. The filter keys can be - all of request parameters. See U(https://www.alibabacloud.com/help/doc-detail/58512.htm) for parameter details. - Filter keys can be same as request parameter name or be lower case and use underscore ("_") or dashes ("-") to - connect different words in one parameter. 'Tag.n.Key' and 'Tag.n.Value' should be a dict and using 'tags' instead. - 'NetworkInterfaceId.N' will be appended to I(eni_ids) automatically. -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.8.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Note: These examples do not set authentication details, see the Alibaba Cloud Guide for details. - -# Gather facts about all ENIs -- ali_eni_facts: - -# Gather facts about a particular ENI -- ali_eni_facts: - eni_ids: - - eni-xxxxxxx - - eni-yyyyyyy - filters: - type: Secondary - -# Gather facts about a particular ENI -- ali_eni_facts: - filters: - network_interface_name: my-test-eni - type: Secondary - -# Gather facts based on vpc and name_prefix -- ali_eni_facts: - name_prefix: foo - filters: - vswitch_id: vpc-dsfh2ef2 -''' - -RETURN = ''' -interfaces: - description: List of matching elastic network interfaces - returned: always - type: complex - contains: - associated_public_ip: - description: The public IP address associated with the ENI. - type: string - sample: 42.1.10.1 - zone_id: - description: The availability zone of the ENI is in. - returned: always - type: string - sample: cn-beijing-a - name: - description: interface name - type: string - sample: my-eni - creation_time: - description: The time the eni was created. - returned: always - type: string - sample: "2018-06-25T04:08Z" - description: - description: interface description - type: string - sample: My new network interface - security_groups: - description: list of security group ids - type: list - sample: [ "sg-f8a8a9da", "sg-xxxxxx" ] - network_interface_id: - description: network interface id - type: string - sample: "eni-123456" - id: - description: network interface id (alias for network_interface_id) - type: string - sample: "eni-123456" - instance_id: - description: Attached instance id - type: string - sample: "i-123456" - mac_address: - description: interface's physical address - type: string - sample: "00:00:5E:00:53:23" - private_ip_address: - description: primary ip address of this interface - type: string - sample: 10.20.30.40 - private_ip_addresses: - description: list of all private ip addresses associated to this interface - type: list of dictionaries - sample: [ { "primary_address": true, "private_ip_address": "10.20.30.40" } ] - state: - description: network interface status - type: string - sample: "pending" - vswitch_id: - description: which vswitch the interface is bound - type: string - sample: vsw-b33i43f3 - vpc_id: - description: which vpc this network interface is bound - type: string - sample: vpc-cj3ht4ogn - type: - description: type of the ENI - type: string - sample: Secondary - tags: - description: Any tags assigned to the ENI. - returned: always - type: dict - sample: {} -ids: - description: List of elastic network interface IDs - returned: always - type: list - sample: [eni-12345er, eni-3245fs] -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - eni_ids=dict(type='list', aliases=['ids']), - name_prefix=dict(), - tags=dict(type='dict'), - filters=dict(type='dict'), - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module ali_eni_facts') - - interfaces = [] - ids = [] - filters = module.params["filters"] - if not filters: - filters = {} - eni_ids = module.params["eni_ids"] - if not eni_ids: - eni_ids = [] - for key, value in list(filters.items()): - if str(key).startswith("NetworkInterfaceId") or \ - str(key).startswith("network_interface_id") or \ - str(key).startswith("network-interface-id"): - if value not in eni_ids: - eni_ids.append(value) - if eni_ids: - filters['network_interface_ids'] = eni_ids - - name_prefix = module.params["name_prefix"] - if module.params['tags']: - filters['tags'] = module.params['tags'] - - try: - for eni in ecs_connect(module).describe_network_interfaces(**filters): - if name_prefix and not str(eni.name).startswith(name_prefix): - continue - interfaces.append(eni.read()) - ids.append(eni.id) - - module.exit_json(changed=False, ids=ids, interfaces=interfaces) - except Exception as e: - module.fail_json(msg=str("Unable to get network interfaces, error:{0}".format(e))) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_image_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_image_facts.py deleted file mode 100644 index e6704fdb..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_image_facts.py +++ /dev/null @@ -1,283 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_image_facts -version_added: "1.5.0" -short_description: Gather facts on images of Alibaba Cloud ECS. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the ECS image itself. - -options: - image_ids: - description: - - A list of ECS image ids. - aliases: [ "ids" ] - image_names: - description: - - A list of ECS image names. - aliases: [ "names" ] -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Fetch disk details according to setting different filters -- name: Fetch image details example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - image_ids: - - m-2zeddnvf7uhw3xwcr6dl - - m-2zeirrrgvh8co3z364f0 - image_names: - - test_image_1 - - test_image_2 - tasks: - - name: Find all images in the specified region - ali_image_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - register: images_by_region - - debug: var=images_by_region - - - name: Find all images in the specified region by image ids - ali_image_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - image_ids: '{{ image_ids }}' - register: images_by_ids - - debug: var=images_by_ids - - - name: Find all images in the specified region by image names - ali_image_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - image_names: '{{ image_names }}' - register: images_by_names - - debug: var=images_by_names - -''' - -RETURN = ''' -image_ids: - description: List all image's id after operating ecs image. - returned: when success - type: list - sample: [ "m-2zeddnvf7uhw3xwcr6dl", "m-2zeirrrgvh8co3z364f0" ] -images: - description: Details about the ecs images. - returned: when success - type: list - sample: [ - { - "architecture": "x86_64", - "creation_time": "2019-03-27T09:47:10Z", - "description": "", - "disk_device_mappings": { - "disk_device_mapping": [ - { - "device": "/dev/xvda", - "format": "", - "import_ossbucket": "", - "import_ossobject": "", - "size": "40", - "snapshot_id": "s-2zeddnvf7uhw3xw3its6", - "type": "system" - } - ] - }, - "image_id": "m-2zeddnvf7uhw3xwcr6dl", - "image_name": "test_image_1", - "image_owner_alias": "self", - "image_version": "", - "is_copied": false, - "is_self_shared": "", - "is_subscribed": false, - "is_support_cloudinit": true, - "is_support_io_optimized": true, - "osname": "CentOS 7.3 64", - "ostype": "linux", - "platform": "CentOS", - "product_code": "", - "progress": "100%", - "region": "cn-beijing", - "size": 40, - "status": "Available", - "tags": {}, - "usage": "none" - }, - { - "architecture": "x86_64", - "creation_time": "2019-03-27T09:47:10Z", - "description": "", - "disk_device_mappings": { - "disk_device_mapping": [ - { - "device": "/dev/xvda", - "format": "", - "import_ossbucket": "", - "import_ossobject": "", - "size": "80", - "snapshot_id": "s-2zeirrrgvh8co3z5nq5d", - "type": "system" - } - ] - }, - "image_id": "m-2zeirrrgvh8co3z364f0", - "image_name": "test_image_2", - "image_owner_alias": "self", - "image_version": "", - "is_copied": false, - "is_self_shared": "", - "is_subscribed": false, - "is_support_cloudinit": true, - "is_support_io_optimized": true, - "osname": "CentOS 7.3 64", - "ostype": "linux", - "platform": "CentOS", - "product_code": "", - "progress": "100%", - "region": "cn-beijing", - "size": 80, - "status": "Available", - "tags": {}, - "usage": "instance" - } - ] -total: - description: The number of all images after operating ecs image. - returned: when success - type: int - sample: 2 -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, ecs_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(image): - """ - Retrieves image information from an image - ID and returns it as a dictionary - """ - return { - 'architecture': image.architecture, - 'creation_time': image.creation_time, - 'description': image.description, - 'disk_device_mappings': image.disk_device_mappings, - 'image_id': image.image_id, - 'image_name': image.image_name, - 'image_owner_alias': image.image_owner_alias, - 'image_version': image.image_version, - 'is_copied': image.is_copied, - 'is_self_shared': image.is_self_shared, - 'is_subscribed': image.is_subscribed, - 'is_support_cloudinit': image.is_support_cloudinit, - 'is_support_io_optimized': image.is_support_io_optimized, - 'platform': image.platform, - 'product_code': image.product_code, - 'progress': image.progress, - "region": image.region, - "size": image.size, - "status": image.status, - "tags": image.tags, - "usage": image.usage, - "osname": image.osname, - "ostype": image.ostype - } - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - image_ids=dict(type='list', aliases=['ids']), - image_names=dict(type='list', aliases=['names']), - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - image_ids = module.params['image_ids'] - image_names = module.params['image_names'] - result = [] - ids = [] - - if image_ids and (not isinstance(image_ids, list) or len(image_ids)) < 1: - module.fail_json(msg='image_ids should be a list of image id, aborting') - - if image_names and (not isinstance(image_names, list) or len(image_names)) < 1: - module.fail_json(msg='image_names should be a list of image name, aborting') - - try: - ecs = ecs_connect(module) - if image_ids: - image_id = ",".join(image_ids) - for image in ecs.get_all_images(image_id=image_id): - result.append(get_info(image)) - ids.append(image.image_id) - - elif image_names: - for name in image_names: - for image in ecs.get_all_images(image_name=name): - if image: - result.append(get_info(image)) - ids.append(image.image_id) - - else: - for image in ecs.get_all_images(): - result.append(get_info(image)) - ids.append(image.image_id) - - module.exit_json(changed=False, image_ids=ids, images=result, total=len(result)) - - except ECSResponseError as e: - module.fail_json(msg='Error in describe images: %s' % str(e)) - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/lib/ansible/modules/cloud/alicloud/_ali_instance_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_instance_facts.py deleted file mode 100644 index 46b3264e..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_instance_facts.py +++ /dev/null @@ -1,428 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_instance_facts -version_added: "2.8" -short_description: Gather facts on instances of Alibaba Cloud ECS. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the ECS instance itself. - -options: - availability_zone: - description: - - (Deprecated) Aliyun availability zone ID in which to launch the instance. Please use filter item 'zone_id' instead. - aliases: ['alicloud_zone'] - instance_names: - description: - - (Deprecated) A list of ECS instance names. Please use filter item 'instance_name' instead. - aliases: [ "names"] - instance_ids: - description: - - A list of ECS instance ids. - aliases: ["ids"] - name_prefix: - description: - - Use a instance name prefix to filter ecs instances. - tags: - description: - - A hash/dictionaries of instance tags. C({"key":"value"}) - aliases: ["instance_tags"] - filters: - description: - - A dict of filters to apply. Each dict item consists of a filter key and a filter value. The filter keys can be - all of request parameters. See U(https://www.alibabacloud.com/help/doc-detail/25506.htm) for parameter details. - Filter keys can be same as request parameter name or be lower case and use underscore ("_") or dash ("-") to - connect different words in one parameter. 'InstanceIds' should be a list and it will be appended to - I(instance_ids) automatically. 'Tag.n.Key' and 'Tag.n.Value' should be a dict and using I(tags) instead. -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.12.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Fetch instances details according to setting different filters -- name: fetch instances details example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - availability_zone: cn-beijing-a - - tasks: - - name: Find all instances in the specified region - ali_instance_facts: - register: all_instances - - name: Find all instances based on the specified ids - ali_instance_facts: - instance_ids: - - "i-35b333d9" - - "i-ddav43kd" - register: instances_by_ids - - name: Find all instances based on the specified name_prefix - ali_instance_facts: - name_prefix: "ecs_instance_" - register: instances_by_name_prefix - -''' - -RETURN = ''' -instances: - description: List of ECS instances - returned: always - type: complex - contains: - availability_zone: - description: The availability zone of the instance is in. - returned: always - type: string - sample: cn-beijing-a - block_device_mappings: - description: Any block device mapping entries for the instance. - returned: always - type: complex - contains: - device_name: - description: The device name exposed to the instance (for example, /dev/xvda). - returned: always - type: string - sample: /dev/xvda - attach_time: - description: The time stamp when the attachment initiated. - returned: always - type: string - sample: "2018-06-25T04:08:26Z" - delete_on_termination: - description: Indicates whether the volume is deleted on instance termination. - returned: always - type: bool - sample: true - status: - description: The attachment state. - returned: always - type: string - sample: in_use - volume_id: - description: The ID of the cloud disk. - returned: always - type: string - sample: d-2zei53pjsi117y6gf9t6 - cpu: - description: The CPU core count of the instance. - returned: always - type: int - sample: 4 - creation_time: - description: The time the instance was created. - returned: always - type: string - sample: "2018-06-25T04:08Z" - description: - description: The instance description. - returned: always - type: string - sample: "my ansible instance" - eip: - description: The attribution of EIP associated with the instance. - returned: always - type: complex - contains: - allocation_id: - description: The ID of the EIP. - returned: always - type: string - sample: eip-12345 - internet_charge_type: - description: The internet charge type of the EIP. - returned: always - type: string - sample: "paybybandwidth" - ip_address: - description: EIP address. - returned: always - type: string - sample: 42.10.2.2 - expired_time: - description: The time the instance will expire. - returned: always - type: string - sample: "2099-12-31T15:59Z" - gpu: - description: The attribution of instane GPU. - returned: always - type: complex - contains: - amount: - description: The count of the GPU. - returned: always - type: int - sample: 0 - spec: - description: The specification of the GPU. - returned: always - type: string - sample: "" - host_name: - description: The host name of the instance. - returned: always - type: string - sample: iZ2zewaoZ - id: - description: Alias of instance_id. - returned: always - type: string - sample: i-abc12345 - instance_id: - description: ECS instance resource ID. - returned: always - type: string - sample: i-abc12345 - image_id: - description: The ID of the image used to launch the instance. - returned: always - type: string - sample: m-0011223344 - instance_charge_type: - description: The instance charge type. - returned: always - type: string - sample: PostPaid - instance_name: - description: The name of the instance. - returned: always - type: string - sample: my-ecs - instance_type_family: - description: The instance type family of the instance belongs. - returned: always - type: string - sample: ecs.sn1ne - instance_type: - description: The instance type of the running instance. - returned: always - type: string - sample: ecs.sn1ne.xlarge - internet_charge_type: - description: The billing method of the network bandwidth. - returned: always - type: string - sample: PayByBandwidth - internet_max_bandwidth_in: - description: Maximum incoming bandwidth from the internet network. - returned: always - type: int - sample: 200 - internet_max_bandwidth_out: - description: Maximum incoming bandwidth from the internet network. - returned: always - type: int - sample: 20 - io_optimized: - description: Indicates whether the instance is optimized for EBS I/O. - returned: always - type: bool - sample: false - memory: - description: Memory size of the instance. - returned: always - type: int - sample: 8192 - network_interfaces: - description: One or more network interfaces for the instance. - returned: always - type: complex - contains: - mac_address: - description: The MAC address. - returned: always - type: string - sample: "00:11:22:33:44:55" - network_interface_id: - description: The ID of the network interface. - returned: always - type: string - sample: eni-01234567 - primary_ip_address: - description: The primary IPv4 address of the network interface within the vswitch. - returned: always - type: string - sample: 10.0.0.1 - osname: - description: The operation system name of the instance owned. - returned: always - type: string - sample: CentOS - ostype: - description: The operation system type of the instance owned. - returned: always - type: string - sample: linux - private_ip_address: - description: The IPv4 address of the network interface within the subnet. - returned: always - type: string - sample: 10.0.0.1 - public_ip_address: - description: The public IPv4 address assigned to the instance or eip address - returned: always - type: string - sample: 43.0.0.1 - resource_group_id: - description: The id of the resource group to which the instance belongs. - returned: always - type: string - sample: my-ecs-group - security_groups: - description: One or more security groups for the instance. - returned: always - type: complex - contains: - - group_id: - description: The ID of the security group. - returned: always - type: string - sample: sg-0123456 - - group_name: - description: The name of the security group. - returned: always - type: string - sample: my-security-group - status: - description: The current status of the instance. - returned: always - type: string - sample: running - tags: - description: Any tags assigned to the instance. - returned: always - type: dict - sample: - vswitch_id: - description: The ID of the vswitch in which the instance is running. - returned: always - type: string - sample: vsw-dew00abcdef - vpc_id: - description: The ID of the VPC the instance is in. - returned: always - type: dict - sample: vpc-0011223344 -ids: - description: List of ECS instance IDs - returned: always - type: list - sample: [i-12345er, i-3245fs] -''' - -# import time -# import sys -import traceback -from ansible.module_utils.basic import AnsibleModule, missing_required_lib -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, ecs_connect - -HAS_FOOTMARK = False -FOOTMARK_IMP_ERR = None -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - FOOTMARK_IMP_ERR = traceback.format_exc() - HAS_FOOTMARK = False - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - availability_zone=dict(aliases=['alicloud_zone']), - instance_ids=dict(type='list', aliases=['ids']), - instance_names=dict(type='list', aliases=['names']), - name_prefix=dict(type='str'), - tags=dict(type='dict', aliases=['instance_tags']), - filters=dict(type='dict') - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - if module._name == 'ali_instance_facts': - module.deprecate("The 'ali_instance_facts' module has been renamed to 'ali_instance_info'", version='2.13') - - if HAS_FOOTMARK is False: - module.fail_json(msg=missing_required_lib('footmark'), exception=FOOTMARK_IMP_ERR) - - ecs = ecs_connect(module) - - instances = [] - instance_ids = [] - ids = module.params['instance_ids'] - name_prefix = module.params['name_prefix'] - names = module.params['instance_names'] - zone_id = module.params['availability_zone'] - if ids and (not isinstance(ids, list) or len(ids) < 1): - module.fail_json(msg='instance_ids should be a list of instances, aborting') - - if names and (not isinstance(names, list) or len(names) < 1): - module.fail_json(msg='instance_names should be a list of instances, aborting') - - filters = module.params['filters'] - if not filters: - filters = {} - if not ids: - ids = [] - for key, value in list(filters.items()): - if key in ["InstanceIds", "instance_ids", "instance-ids"] and isinstance(ids, list): - for id in value: - if id not in ids: - ids.append(value) - if ids: - filters['instance_ids'] = ids - if module.params['tags']: - filters['tags'] = module.params['tags'] - if zone_id: - filters['zone_id'] = zone_id - if names: - filters['instance_name'] = names[0] - - for inst in ecs.describe_instances(**filters): - if name_prefix: - if not str(inst.instance_name).startswith(name_prefix): - continue - volumes = ecs.describe_disks(instance_id=inst.id) - setattr(inst, 'block_device_mappings', volumes) - setattr(inst, 'user_data', inst.describe_user_data()) - instances.append(inst.read()) - instance_ids.append(inst.id) - - module.exit_json(changed=False, ids=instance_ids, instances=instances) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_oss_bucket_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_oss_bucket_facts.py deleted file mode 100644 index 5ce28d14..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_oss_bucket_facts.py +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_oss_bucket_facts -version_added: "1.5.0" -short_description: Gather facts on buckets of Alibaba Cloud OSS. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the OSS bucket itself. - -options: - bucket: - description: - - OSS bucket name. - aliases: [ 'name' ] - bucket_prefix: - description: - - Prefix of OSS bucket name. -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# -# provisioning list oss buckets -# - -# Basic provisioning example to create bucket -- name: List buckets detail example - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - bucket: buctest1 - bucket_prefix: buctest1 - tasks: - - name: List all buckets in the specified region - ali_oss_bucket_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - bucket: '{{ bucket }}' - register: all_buckets - - debug: var=all_buckets - - - name: List all buckets in the specified region by name - ali_oss_bucket_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - bucket: '{{ bucket }}' - bucket_prefix: '{{ bucket_prefix }}' - register: buckets_by_name - - debug: var=buckets_by_name -''' - -RETURN = ''' -bucket_names: - description: List all bucket's names in specified region. - returned: when success - type: list - sample: ["xiaozhubucket", "testbucket"] -buckets: - description: The list all buckets that has the prefix of 'bucket' value in the specified region - returned: when list - type: list - sample: [ - { - "id": "xiaozhubucket", - "location": "oss-cn-beijing", - "name": "xiaozhubucket", - "permission": "private" - }, - { - "id": "testbucket", - "location": "oss-cn-beijing", - "name": "testbucket", - "permission": "public-read-write" - } - ] -total: - description: The number of all buckets available in region. - returned: when success - type: int - sample: 2 -''' - - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_oss import oss_bucket_argument_spec, oss_bucket_connect, oss_service_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError, OSSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(bucket): - return { - 'id': bucket.id, - 'name': bucket.name, - 'permission': bucket.acl, - 'location': bucket.location - } - - -def main(): - argument_spec = oss_bucket_argument_spec() - argument_spec.update( - dict( - bucket=dict(aliases=["name"]), - bucket_prefix=dict(type="str") - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - try: - oss_service = oss_service_connect(module) - keys = oss_service.list_buckets(prefix=module.params['bucket_prefix'], max_keys=200) - - buckets = [] - bucket_names = [] - for name in keys: - module.params['bucket'] = name - bucket = oss_bucket_connect(module) - buckets.append(get_info(bucket)) - bucket_names.append(bucket.name) - - module.exit_json(changed=False, bucket_names=bucket_names, buckets=buckets, total=len(buckets)) - except Exception as e: - module.fail_json(msg="Unable to describe buckets, and got an error: {0}.".format(e)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_oss_object_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_oss_object_facts.py deleted file mode 100644 index 2ad6e281..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_oss_object_facts.py +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_oss_object_facts -version_added: "1.5.0" -short_description: Gather facts on bucket objects of Alibaba Cloud OSS. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the OSS bucket itself. -options: - bucket: - description: - - OSS bucket name. - object: - description: - - Bucket object name. - aliases: [ 'object_name' ] -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Fetch object details in the specified bucket -- name: List objects detail example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - bucket: xiaozhubucket - object: newobject-1 - tasks: - - name: List all objects in the specified bucket - ali_oss_object_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - bucket: '{{ bucket }}' - register: all_objects_in_bucket - - debug: var=all_objects_in_bucket - - - name: List all objects that has the prefix of 'object' value in the specified bucket - ali_oss_object_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - bucket: '{{ bucket }}' - object: '{{ object }}' - register: all_objects_by_name - - debug: var=all_objects_by_name -''' - -RETURN = ''' -object_names: - description: List all object's in the specified bucket - returned: when success - type: list - sample: ["newobject-1", "newobject-2", "newobject-3"] -objects: - description: The list all objects that has the prefix of 'object' value in the specified bucket - returned: when list - type: list - sample: [ - { - "etag": "64C63F0FCB9ABA4F74A3DF3A491BBC7A", - "key": "newobject-1", - "last_modified": "2017-10-26 15:18:38", - "size": "1843 B", - "storage_class": "Standard", - "type": "Normal" - }, - { - "etag": "BE13E8EF0FB40070727817E1448345A0", - "key": "newobject-2", - "last_modified": "2017-10-26 15:18:38", - "size": "15624 B", - "storage_class": "Standard", - "type": "Normal" - }, - { - "etag": "A7D40C705F555AD8B0A9557BBCCB1178", - "key": "newobject-3", - "last_modified": "2017-10-26 15:18:40", - "size": "3541 B", - "storage_class": "Standard", - "type": "Normal" - } - ] -total: - description: The number of all object's in the specified bucket. - returned: when success - type: int - sample: 3 -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_oss import oss_bucket_argument_spec, oss_bucket_connect -import time - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError, OSSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(obj): - result = { - 'key': obj.key, - 'last_modified': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(obj.last_modified)), - 'etag': obj.etag, - 'type': obj.type, - 'size': str(obj.size) + ' B', - 'storage_class': obj.storage_class - } - - if obj.type == 'Appendable': - result['next_append_position'] = obj.size - - return result - - -def main(): - argument_spec = oss_bucket_argument_spec() - argument_spec.update(dict( - bucket=dict(type='str', required=True), - object=dict(type='str', aliases=['key', 'object_name']), - )) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - object_key = module.params['object'] - objects = [] - object_names = [] - max_keys = 500 - - try: - oss_bucket = oss_bucket_connect(module) - - while True: - results = oss_bucket.list_objects(prefix=object_key, max_keys=max_keys) - for obj in results: - objects.append(get_info(obj)) - object_names.append(obj.key) - - if len(results) < max_keys: - break - module.exit_json(changed=False, object_names=object_names, objects=objects, total=len(objects)) - except Exception as e: - module.fail_json(msg="Unable to describe bucket objects, and got an error: {0}".format(e)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_rds_account_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_rds_account_facts.py deleted file mode 100644 index ac5d583e..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_rds_account_facts.py +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: ali_rds_account_facts -version_added: "1.5.0" -short_description: Gather facts on RDS accounts of Alibaba Cloud. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the RDS account itself. -options: - db_instance_id: - description: - - ID of RDS instance. - account_names: - description: - - A list of RDS account names. - aliases: ["names"] -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark" -extends_documentation_fragment: - - alicloud -""" - -EXAMPLES = """ -# Fetch rds account details according to setting different filters -- name: fetch rds account details example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - db_instance_id: rm-dj13c34832w21g47j - account_names: - - demoaccount - - testaccount - tasks: - - name: Find all accounts in the rds instance - ali_rds_account_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - db_instance_id: '{{ db_instance_id }}' - register: all_accounts - - debug: var=all_accounts - - - name: Find accounts in the rds instance by account name - ali_rds_account_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - db_instance_id: '{{ db_instance_id }}' - account_names: '{{ account_names }}' - register: accounts_by_name - - debug: var=accounts_by_name -""" - -RETURN = ''' -account_names: - description: List all account's name of rds instance. - returned: when success - type: list - sample: [ "demoaccount", "testaccount" ] -rds_accounts: - description: Details about the rds accounts that were created. - returned: when success - type: list - sample: [ - { - "account_description": "", - "account_name": "demoaccount", - "account_status": "Available", - "account_type": "Normal", - "database_privileges": { - "database_privilege": [] - }, - "db_instance_id": "rm-dj13c34832w21g47j" - }, - { - "account_description": "", - "account_name": "testaccount", - "account_status": "Available", - "account_type": "Normal", - "database_privileges": { - "database_privilege": [] - }, - "db_instance_id": "rm-dj13c34832w21g47j" - } - ] -total: - description: The number of all rds accounts. - returned: when success - type: int - sample: 2 -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, rds_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import RDSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(obj): - """ - get info from account obj - :type obj: account object - :param obj: the object of account - :return: dict of account info - """ - if obj: - return dict(db_instance_id=obj.dbinstance_id, - account_name=obj.account_name, - account_status=obj.account_status, - account_type=obj.account_type, - account_description=obj.account_description, - database_privileges=obj.database_privileges) - return {} - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - db_instance_id=dict(type='str', required=True), - account_names=dict(type='list', aliases=['names']) - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json("Package 'footmark' required for this module.") - - # Get values of variable - db_instance_id = module.params['db_instance_id'] - names = module.params['account_names'] - result = [] - - try: - rds = rds_connect(module) - - if names and (not isinstance(names, list) or len(names)) < 1: - module.fail_json(msg='account_name should be a list of account name, aborting') - - # fetch rds accounts by name - if names: - for name in names: - rds_accounts = rds.list_account(db_instance_id=db_instance_id, account_name=name) - if rds_accounts and len(rds_accounts) == 1: - result.append(get_info(rds_accounts[0])) - - # fetch all rds accounts - else: - names = [] - for account in rds.list_account(db_instance_id=db_instance_id): - names.append(account.account_name) - result.append(get_info(account)) - - module.exit_json(changed=False, account_names=names, rds_accounts=result, total=len(result)) - except Exception as e: - module.fail_json(msg="Unable to describe rds accounts, and got an error: {0}.".format(e)) - - -if __name__ == "__main__": - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_rds_instance_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_rds_instance_facts.py deleted file mode 100644 index 5cd04b5e..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_rds_instance_facts.py +++ /dev/null @@ -1,302 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_rds_instance_facts -version_added: "1.5.0" -short_description: Gather facts on database instance of Alibaba Cloud RDS. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the RDS instance itself. - -options: - instance_ids: - description: - - A list of RDS database instance ids. - aliases: [ "db_instance_ids" ] - engine: - description: - - Type of the database. - dbinstance_type: - description: - - Instance type. - instance_network_type: - description: - - Instance network type. - connection_mode: - description: - - Instance connection mode. - tags: - description: - - Database tags. - -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Fetch database instance details according to setting different filters -- name: fetch database instance details example - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - engine: MySQL - dbinstance_type: Temp - instance_network_type: Classic - connection_mode: Safe - tags: - rds: '01' - instance_ids: - - rm-dj163498yvlgy80ug - tasks: - - name: Find all database instance in the specified region - ali_rds_instance_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - register: all_db_instance - - debug: var=all_db_instance - - - name: Find all database instance in the specified region based on instance ids - ali_rds_instance_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance_ids }}' - register: db_instance_by_ids - - debug: var=db_instance_by_ids - - - name: Find all database instance in the specified region based on database instance type - ali_rds_instance_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance_ids }}' - engine: '{{ engine }}' - register: db_instance_by_dbtype - - debug: var=db_instance_by_dbtype - - - name: Find all database instance in the specified region based on instance type - ali_rds_instance_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance_ids }}' - dbinstance_type: '{{ dbinstance_type }}' - register: db_instance_by_type - - debug: var=db_instance_by_type - - - name: Find all database instance in the specified region based on instance network type - ali_rds_instance_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance_ids }}' - instance_network_type: '{{ instance_network_type }}' - register: db_instance_by_network_type - - debug: var=db_instance_by_network_type - - - name: Find all database instance in the specified region based on instance connection mode and tags - ali_rds_instance_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance_ids }}' - connection_mode: '{{ connection_mode }}' - tags: '{{ tags }}' - register: db_instance_by_connection_mode - - debug: var=db_instance_by_connection_mode -''' - -RETURN = ''' -instance_ids: - description: List all database instance's id after operating RDS database instances. - returned: when success - type: list - sample: [ "rm-dj1d7a046kur7syix", "rm-dj164ju77728joefu" ] -rds_db_instances: - description: Details about the rds database instances that were created. - returned: when success - type: list - sample: [ - { - "connection_mode": "Safe", - "create_time": "2017-11-07T18:47Z", - "dbinstance_class": "rds.mysql.t1.small", - "dbinstance_id": "rm-dj1d7a046kur7syix", - "dbinstance_net_type": "Intranet", - "dbinstance_status": "Running", - "dbinstance_type": "Primary", - "engine": "MySQL", - "engine_version": "5.6", - "expire_time": "", - "ins_id": 1, - "instance_network_type": "Classic", - "lock_mode": "Unlock", - "lock_reason": "", - "mutri_orsignle": false, - "pay_type": "Postpaid", - "read_only_dbinstance_ids": { - "read_only_dbinstance_id": [] - }, - "region_id": "cn-beijing", - "resource_group_id": "rg-acfmv53ndviljcy", - "zone_id": "cn-beijing-a" - }, - { - "connection_mode": "Safe", - "create_time": "2017-11-07T18:23Z", - "dbinstance_class": "rds.mysql.t1.small", - "dbinstance_id": "rm-dj164ju77728joefu", - "dbinstance_net_type": "Intranet", - "dbinstance_status": "Running", - "dbinstance_type": "Primary", - "engine": "MySQL", - "engine_version": "5.6", - "expire_time": "", - "ins_id": 1, - "instance_network_type": "Classic", - "lock_mode": "Unlock", - "lock_reason": "", - "mutri_orsignle": false, - "pay_type": "Postpaid", - "read_only_dbinstance_ids": { - "read_only_dbinstance_id": [] - }, - "region_id": "cn-beijing", - "resource_group_id": "rg-acfmv53ndviljcy", - "zone_id": "cn-beijing-a" - } - ] -total: - description: The number of all database instances after operating RDS database instances. - returned: when success - type: int - sample: 2 -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect, vpc_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import RDSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(obj): - if not obj: - return None - return dict( - resource_group_id=obj.resource_group_id, - region_id=obj.region_id, - mutri_orsignle=obj.mutri_orsignle, - create_time=obj.create_time, - dbinstance_class=obj.dbinstance_class, - dbinstance_net_type=obj.dbinstance_net_type, - lock_mode=obj.lock_mode, - pay_type=obj.pay_type, - read_only_dbinstance_ids=obj.read_only_dbinstance_ids, - dbinstance_type=obj.dbinstance_type, - engine=obj.engine, - instance_network_type=obj.instance_network_type, - dbinstance_status=obj.dbinstance_status, - expire_time=obj.expire_time, - dbinstance_id=obj.dbinstance_id, - zone_id=obj.zone_id, - lock_reason=obj.lock_reason, - connection_mode=obj.connection_mode, - ins_id=obj.ins_id, - engine_version=obj.engine_version - ) - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - instance_ids=dict(type='list', aliases=['db_instance_ids']), - engine=dict(type='str'), - dbinstance_type=dict(type='str'), - instance_network_type=dict(type='str'), - connection_mode=dict(type='str'), - tags = dict(type='dict') - )) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - result = [] - ids = [] - instance_ids = module.params['instance_ids'] - engine = module.params['engine'] - dbinstance_type = module.params['dbinstance_type'] - instance_network_type = module.params['instance_network_type'] - connection_mode = module.params['connection_mode'] - tags = module.params['tags'] - - if instance_ids and (not isinstance(instance_ids, list) or len(instance_ids)) < 1: - module.fail_json(msg='instance_ids should be a list of db_instance id, aborting') - - try: - rds = rds_connect(module) - # list rds db_instance by instance ids - if instance_ids: - instance_id = ",".join(instance_ids) - - for rds_instance in rds.get_rds_instances(instance_id=instance_id, engine=engine, - dbinstance_type=dbinstance_type, - instance_network_type=instance_network_type, - connection_mode=connection_mode, tags=tags): - result.append(get_info(rds_instance)) - ids.append(rds_instance.dbinstance_id) - - # list all db_instance available in specified region - else: - for rds_instance in rds.get_rds_instances(): - result.append(get_info(rds_instance)) - ids.append(rds_instance.dbinstance_id) - - except Exception as e: - module.fail_json(msg="Unable to describe rds db instance, and got an error: {0}.".format(e)) - - module.exit_json(changed=False, db_instance_ids=ids, rds_db_instances=result, total=len(result)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_route_entry_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_route_entry_facts.py deleted file mode 100644 index ac1bec04..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_route_entry_facts.py +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_route_entry_facts -version_added: "1.5.0" -short_description: Gather facts on vrouter of Alibaba Cloud. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the VRouter itself. - -options: - vrouter_id: - description: - - Id of vrouter of vpc - aliases: ["id"] - route_table_id: - description: - - The ID of the route table. -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Fetch vrouter details according to setting different filters -- name: Fetch vroute entry details example - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - vrouter_id: xxxxxxxxxxxxx - route_table_id: xxxxxxxxxxxxx - - tasks: - - name: Find all vroute_entries in the specified vroute - ali_route_entry_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - vrouter_id: '{{ vrouter_id }}' - register: result - - debug: var=result - - - name: Find all vroute_entries in the specified vroute by route table id - ali_route_entry_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - vrouter_id: '{{ vrouter_id }}' - route_table_id: '{{ route_table_id }}' - register: result_by_tbl_id - - debug: var=result_by_tbl_id - -''' - -RETURN = ''' -vrouter_id: - description: VRouter id after operating VRouter. - returned: when success - type: str - sample: "vrt-2ze60agfbr2wcyt08jfov" -vroute_entries: - description: Details about the VRouter that were created. - returned: when success - type: list - sample: [ - { - "destination_cidr_block": "192.168.5.0/28", - "instance_id": "", - "next_hop_type": "local", - "next_hops": { - "next_hop": [] - }, - "region": "cn-beijing", - "route_table_id": "vtb-2ze1rxml89cl7828yc08g", - "status": "Available", - "tags": {}, - "type": "System" - }, - { - "destination_cidr_block": "192.168.1.0/24", - "instance_id": "", - "next_hop_type": "local", - "next_hops": { - "next_hop": [] - }, - "region": "cn-beijing", - "route_table_id": "vtb-2ze1rxml89cl7828yc08g", - "status": "Available", - "tags": {}, - "type": "System" - }, - { - "destination_cidr_block": "100.64.0.0/10", - "instance_id": "", - "next_hop_type": "service", - "next_hops": { - "next_hop": [] - }, - "region": "cn-beijing", - "route_table_id": "vtb-2ze1rxml89cl7828yc08g", - "status": "Available", - "tags": {}, - "type": "System" - } - ] -total: - description: The number of all route entries in vrouter. - returned: when success - type: int - sample: 3 -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import VPCResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(route_entry): - """ - Retrieves route entry information from an route entry - ID and returns it as a dictionary - """ - return { - 'destination_cidr_block': route_entry.destination_cidr_block, - 'instance_id': route_entry.instance_id, - 'next_hop_type': route_entry.next_hop_type, - 'next_hops': route_entry.next_hops, - 'region': route_entry.region, - 'route_table_id': route_entry.route_table_id, - 'status': route_entry.status, - 'tags': route_entry.tags, - 'type': route_entry.type, - 'route_entry_id': route_entry.route_entry_id, - 'route_entry_name': route_entry.route_entry_name - } - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - vrouter_id=dict(type='str', required=True, aliases=['id']), - route_table_id=dict(type='str') - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - result = [] - vrouter_id = module.params['vrouter_id'] - route_table_id = module.params['route_table_id'] - - - try: - vpc_conn = vpc_connect(module) - - # list all route entries in vrouter - if vrouter_id: - vrouter_entries = vpc_conn.get_all_route_entries(router_id=vrouter_id, route_table_id=route_table_id) - for vrouter_entry in vrouter_entries: - result.append(get_info(vrouter_entry)) - except Exception as e: - module.fail_json(msg="Unable to describe vrouter entries, and got an error: {0}.".format(e)) - - module.exit_json(changed=False, vrouter_id=vrouter_id, vroute_entries=result, total=len(result)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_security_group_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_security_group_facts.py deleted file mode 100644 index f51df975..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_security_group_facts.py +++ /dev/null @@ -1,255 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_security_group_facts -version_added: "2.8" -short_description: Gather facts on security group of Alibaba Cloud ECS. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the ECS security group itself. - -options: - group_ids: - description: - - A list of ECS security group IDs. - aliases: ["ids"] - group_name: - description: - - (Deprecated) Name of the security group. New option `name_prefix` instead. - aliases: ["name"] - name_prefix: - description: - - Use a Security Group name prefix to filter security group. - tags: - description: - - A hash/dictionaries of security group tags. C({"key":"value"}) - filters: - description: - - A dict of filters to apply. Each dict item consists of a filter key and a filter value. The filter keys can be - all of request parameters. See U(https://www.alibabacloud.com/help/doc-detail/25556.htm) for parameter details. - Filter keys can be same as request parameter name or be lower case and use underscores ("_") or dashes ("-") to - connect different words in one parameter. "Tag.n.Key" and "Tag.n.Value" use new filter I(tags) instead and - it should be a dict. "SecurityGroupIds" should be a list and it will be appended to I(group_ids) automatically. -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.7.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Note: These examples do not set authentication details, see the Alibaba Cloud Guide for details. - -# Gather facts about all security groups -- ali_security_group_facts: - -# Gather facts about all security groups in a specific VPC -- ali_security_group_facts: - filters: - vpc-id: vpc-12345678 - -# Gather facts about a security group using a name_prefix -- ali_security_group_facts: - name_prefix: example - -# Gather facts about a security group by id -- ali_security_group_facts: - group_ids: - - sg-12345678 - - sg-cnqwu234 - -# Gather facts about any security group with a tag key Name and value Example. -- ali_security_group_facts: - tags: - name: Example - env: dev -''' - -RETURN = ''' -ids: - description: list IDs of security groups - returned: always - type: list - sample: ["sg-2ze12578be1ls4wcjhfd", "sg-2ze28n1vj1iqztxp7p6h"] -groups: - description: Returns an array of complex objects as described below. - returned: always - type: complex - contains: - description: - description: The Security Group description. - returned: always - type: string - sample: "my ansible group" - group_name: - description: Security group name - sample: "my-ansible-group" - type: string - returned: always - group_id: - description: Security group id - sample: sg-abcd1234 - type: string - returned: always - id: - description: Alias of "group_id". - sample: sg-abcd1234 - type: string - returned: always - inner_access_policy: - description: Whether can access each other in one security group. - sample: True - type: bool - returned: always - tags: - description: Tags associated with the security group - sample: - Name: My Security Group - From: Ansible - type: dict - returned: always - vpc_id: - description: ID of VPC to which the security group belongs - sample: vpc-abcd1234 - type: string - returned: always - permissions: - description: Inbound rules associated with the security group. - sample: - - create_time: "2018-06-28T08:45:58Z" - description: "None" - dest_cidr_ip: "None" - dest_group_id: "None" - dest_group_name: "None" - dest_group_owner_account: "None" - direction: "ingress" - ip_protocol: "TCP" - nic_type: "intranet" - policy: "Accept" - port_range: "22/22" - priority: 1 - source_cidr_ip: "0.0.0.0/0" - source_group_id: "None" - source_group_name: "None" - source_group_owner_account: "None" - type: list - returned: always - permissions_egress: - description: Outbound rules associated with the security group. - sample: - - ip_protocol: -1 - ip_ranges: - - create_time: "2018-06-28T08:45:59Z" - description: "NOne" - dest_cidr_ip: "192.168.0.54/32" - dest_group_id: "None" - dest_group_name: "None" - dest_group_owner_account: "None" - direction: "egress" - ip_protocol: "TCP" - nic_type: "intranet" - policy: "Accept" - port_range: "80/80" - priority: 1 - source_cidr_ip: "None" - source_group_id: "None" - source_group_name: "None" - source_group_owner_account: "None" - type: list - returned: always -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect - - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - group_name=dict(aliases=['name']), - name_prefix=dict(), - tags=dict(type='dict'), - group_ids=dict(type='list', aliases=['ids']), - filters=dict(type='dict') - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - ecs = ecs_connect(module) - - filters = module.params["filters"] - if not filters: - filters = {} - - group_ids = module.params['group_ids'] - if not group_ids: - group_ids = [] - for key, value in list(filters.items()): - if key in ["SecurityGroupIds", "security_group_ids", "security_group_ids"] and isinstance(group_ids, list): - for id in value: - if id not in group_ids: - group_ids.append(id) - if group_ids: - filters["security_group_ids"] = group_ids - - name = module.params['group_name'] - name_prefix = module.params['name_prefix'] - if module.params['tags']: - filters['tags'] = module.params['tags'] - - changed = False - groups = [] - ids = [] - try: - for sg in ecs.describe_security_groups(**filters): - if name and sg.security_group_name != name: - continue - if name_prefix and not str(sg.security_group_name).startswith(name_prefix): - continue - groups.append(sg.read()) - ids.append(sg.id) - except ECSResponseError as e: - module.fail_json(msg='Error in describe_security_groups: {0}'.format(e)) - - module.exit_json(changed=changed, ids=ids, groups=groups) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_slb_lb_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_slb_lb_facts.py deleted file mode 100644 index 235f9bd4..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_slb_lb_facts.py +++ /dev/null @@ -1,317 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_slb_lb_facts -version_added: "2.8" -short_description: Gather facts on server load balancer of Alibaba Cloud. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the SLB itself. - -options: - load_balancer_name: - description: - - (Deprecated) A list of server laod balancer names. New option `name_prefix` instead. - aliases: ["name"] - load_balancer_ids: - description: - - A list of load balancer IDs to gather facts for. - aliases: ['ids'] - name_prefix: - description: - - Use a load balancer name prefix to filter load balancers. - filters: - description: - - A dict of filters to apply. Each dict item consists of a filter key and a filter value. The filter keys can be - all of request parameters. See U(https://www.alibabacloud.com/help/doc-detail/27582.htm) for parameter details. - Filter keys can be same as request parameter name or be lower case and use underscores ("_") or dashes ("-") to - connect different words in one parameter. 'LoadBalancerId' will be appended to I(load_balancer_ids) automatically. -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.9.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Note: These examples do not set authentication details, see the Alibaba Cloud Guide for details. -- name: Retrieving slbs using ids - ali_slb_lb_facts: - ids: 'lb-sn33f3' - -- name: Filter slb using name_regex - ali_slb_lb_facts: - name_prefix: 'ansible-slb' - -- name: Retrieving all slbs - ali_slb_lb_facts: -''' - -RETURN = ''' -ids: - description: List ids of being fetched slb. - returned: when success - type: list - sample: ["lb-dj1oi1h5l74hg22gsnugf", "lb-dj1t1xwn0y9zcr90e52i2"] -names: - description: List names of being fetched slb. - returned: when success - type: list - sample: ["ansible-foo", "ansible-bar"] -load_balancers: - description: - - info about the server load balancer that was created or deleted. - returned: on present - type: complex - contains: - address: - description: The IP address of the loal balancer - returned: always - type: string - sample: "47.94.26.126" - address_ipversion: - description: The IP address version. IPV4 or IPV6. - returned: always - type: string - sample: "ipv4" - address_type: - description: The load balancer internet type - returned: always - type: string - sample: "internet" - backend_servers: - description: The load balancer's backend servers - returned: always - type: complex - contains: - server_id: - description: The backend server id - returned: always - type: string - sample: "i-vqunci342" - weight: - description: The backend server weight - returned: always - type: int - sample: 100 - description: - description: The backend server description - returned: always - type: string - sample: "" - type: - description: The backend server type, ecs or eni - returned: always - type: string - sample: "ecs" - bandwidth: - description: The load balancer internet bandwidth - returned: always - type: int - sample: 5 - create_time: - description: The time of the load balancer was created - returned: always - type: string - sample: "2019-01-02T02:37:41Z" - end_time: - description: The time of the load balancer will be released - returned: always - type: string - sample: "2999-09-08T16:00:00Z" - id: - description: The ID of the load balancer was created. Same as load_balancer_id. - returned: always - type: string - sample: "lb-2zea9ohgtf" - internet_charge_type: - description: The load balancer internet charge type - returned: always - type: string - sample: "PayByTraffic" - listeners: - description: The listeners of the load balancer. - returned: always - type: complex - contains: - listener_port: - description: The front-end port of the listener that is used to receive incoming traffic and - distribute the traffic to the backend servers. - returned: always - type: int - sample: 22 - listener_protocol: - description: The frontend protocol used by the SLB instance. - returned: always - type: string - sample: tcp - listener_forward: - description: Whether to enable listener forwarding. - returned: always - type: string - sample: "" - forward_port: - description: The destination listening port. It must be an existing HTTPS listening port. - returned: always - type: int - sample: 20 - load_balancer_id: - description: The ID of the load balancer was created. - returned: always - type: string - sample: "lb-2zea9ohgtf" - load_balancer_name: - description: The name of the load balancer was created. - returned: always - type: string - sample: "ansible-ali_slb_lb" - load_balancer_status: - description: The load balancer current status. - returned: always - type: string - sample: "active" - master_zone_id: - description: The ID of the primary zone. - returned: always - type: string - sample: "cn-beijing-a" - name: - description: The name of the load balancer was created. - returned: always - type: string - sample: "ansible-ali_slb_lb" - network_type: - description: The network type of the load balancer was created. - returned: always - type: string - sample: "classic" - pay_type: - description: The load balancer instance charge type. - returned: always - type: string - sample: "PostPaid" - resource_group_id: - description: The resource group of the load balancer belongs. - returned: always - type: string - sample: "rg-acfmwvvtg5owavy" - slave_zone_id: - description: The ID of the backup zone - returned: always - type: string - sample: "cn-beijing-d" - tags: - description: The load balancer tags - returned: always - type: complex - sample: {} - vpc_id: - description: The vpc of the load balancer belongs. - returned: always - type: string - sample: "vpc-fn3nc3" - vswitch_id: - description: The vswitch of the load balancer belongs. - returned: always - type: string - sample: "vsw-c3nc3r" -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import SLBResponseError - - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - load_balancer_name=dict(type='list', aliases=['name']), - load_balancer_ids=dict(type='list', aliases=['ids']), - name_prefix=dict(type='str'), - filters=dict(type='dict') - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - lb_ids = module.params['load_balancer_ids'] - if not lb_ids: - lb_ids = [] - name_prefix = module.params['name_prefix'] - filters = module.params['filters'] - if not filters: - filters = {} - for key, value in list(filters.items()): - if key in ["LoadBalancerId", "load-balancer-id", "load_balancer_id"] and value not in lb_ids: - lb_ids.append(value) - lbs = [] - ids = [] - names = [] - - try: - slb = slb_connect(module) - if len(lb_ids) > 0: - for index in range(0, len(lb_ids), 10): - ids_tmp = lb_ids[index:index + 10] - if not ids_tmp: - break - filters['load_balancer_id'] = ",".join(ids_tmp) - - for lb in slb.describe_load_balancers(**filters): - if name_prefix and not str(lb.load_balancer_name).startswith(name_prefix): - continue - lbs.append(lb.read()) - ids.append(lb.load_balancer_id) - names.append(lb.load_balancer_name) - else: - for lb in slb.describe_load_balancers(**filters): - if name_prefix and not str(lb.load_balancer_name).startswith(name_prefix): - continue - lbs.append(lb.read()) - ids.append(lb.load_balancer_id) - names.append(lb.load_balancer_name) - - module.exit_json(changed=False, load_balancers=lbs, ids=ids, names=names) - except Exception as e: - module.fail_json(msg="Unable to describe server load balancers, and got an error: {0}.".format(e)) - - -if __name__ == "__main__": - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_slb_listener_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_slb_listener_facts.py deleted file mode 100644 index 3d2c0607..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_slb_listener_facts.py +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: ali_slb_listener_facts -version_added: "1.5.0" -short_description: Gather facts on listener of Alibaba Cloud SLB. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the SLB listeners itself. - -options: - load_balancer_id: - description: - - ID of server load balancer. - required: true - aliases: [ "lb_id" ] - listener_type: - description: - - User expects the type of operation listener. - required: true - choices: [ 'http', 'https', 'tcp', 'udp'] - listener_port: - description: - - Port used by the Server Load Balancer instance frontend - required: true - choices: [1~65535] -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark" -extends_documentation_fragment: - - alicloud -""" - -EXAMPLES = """ -# Fetch SLB listener details according to setting different filters -- name: Fetch SLB listener details example - hosts: localhost - vars: - alicloud_region: cn-beijing - alicloud_access_key: - alicloud_secret_key: - load_balancer_id: lb-dj1jywbux1zslfna6pvnv - listener_type: http - listener_port: 8085 - tasks: - - name: Fetch SLB listener details example - ali_slb_listener_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - listener_type: '{{ listener_type }}' - listener_port: '{{ listener_port }}' - register: result - - debug: var=result -""" - -RETURN = ''' -listener: - description: Details about SLB listener that were created. - returned: when success - type: dict - sample: { - "backend_server_port": 8085, - "bandwidth": 1, - "listener_port": 8085, - "listener_type": null, - "persistence_timeout": null, - "schedule": null, - "server_certificate_id": null, - "status": "stopped", - "sticky_session": "off" - } -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, slb_connect - -HAS_ECS = False -HAS_FOOTMARK = False - -try: - from footmark.exception import SLBResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(obj): - """ - get info from lb object - :param obj: lb obj - :return: info of lb - """ - result = dict(listener_port=obj.listener_port, - backend_server_port=obj.backend_server_port, - bandwidth=obj.bandwidth, - status=obj.status, - schedule=obj.schedule, - listener_type=obj.listener_type) - - if hasattr(obj, 'server_certificate_id'): - result['server_certificate_id'] = obj.server_certificate_id - if hasattr(obj, 'sticky_session'): - result['sticky_session'] = obj.sticky_session - if hasattr(obj, 'persistence_timeout'): - result['persistence_timeout'] = obj.persistence_timeout - return result - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - listener_port=dict(type='int', required=True, choices=[i for i in range(1, 65536)]), - load_balancer_id=dict(type='str', aliases=['lb_id']), - listener_type=dict(type='str', choices=['http', 'https', 'tcp', 'udp']) - )) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - load_balancer_id = module.params['load_balancer_id'] - listener_port = module.params['listener_port'] - listener_type = module.params['listener_type'] - - try: - slb = slb_connect(module) - - # check whether server load balancer exist or not - laod_balancer = slb.describe_load_balancers(load_balancer_id=load_balancer_id) - if laod_balancer and len(laod_balancer) == 1: - - # list load balancers listeners - listener = slb.describe_load_balancer_listener_attribute(load_balancer_id, - listener_port, - listener_type) - if listener is None: - module.fail_json(msg="Unable to describe slb listeners, no listeners found") - else: - module.exit_json(changed=False, listener=get_info(listener)) - else: - module.fail_json(msg="Unable to describe slb listeners, invalid load balancer id") - except Exception as e: - module.fail_json(msg="Unable to describe slb listeners, and got an error: {0}.".format(e)) - - -if __name__ == "__main__": - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_slb_server_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_slb_server_facts.py deleted file mode 100644 index de363622..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_slb_server_facts.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: ali_slb_server_facts -version_added: "1.5.0" -short_description: Gather facts on backend server of Alibaba Cloud SLB. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the SLB backend server itself. -options: - load_balancer_id: - description: - - ID of server load balancer. - required: true - aliases: [ "lb_id" ] - listener_ports: - description: - - A list of backend server listening ports. - aliases: [ "ports" ] -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark" -extends_documentation_fragment: - - alicloud -""" - -EXAMPLES = ''' -# Fetch backend server health status details according to setting different filters -- name: fetch backend server health status in the specified region - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - load_balancer_id: lb-dj1e5kwh41n87vkn1pxn5 - ports: - - 100 - - 90 - tasks: - - name: Find all backend server health status in specified region - ali_slb_server_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - register: all_backend_server - - debug: var=all_backend_server - - - name: Find all backend server health status based on specified port no. - ali_slb_server_facts: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - listener_ports: '{{ ports }}' - register: backend_servera_by_ports - - debug: var=backend_servera_by_ports -''' - -RETURN = ''' -load_balancer_id: - description: ID of the load balancer. - returned: when success - type: string - sample: "lb-dj1jywbux1zslfna6pvnv" -"backend_servers": - description: Details about the backened-servers that were added. - returned: when success - type: list - sample: [ - { - "id": "i-2ze35dldjc05dcvezgwk", - "listener_port": 80, - "port": 80, - "server_health_status": "unavailable" - }, - { - "id": "i-2ze35dldjc05dcvezgwk", - "listener_port": 8080, - "port": 8080, - "server_health_status": "unavailable" - }, - { - "id": "i-2ze35dldjc05dcvezgwk", - "listener_port": 8085, - "port": 8085, - "server_health_status": "unavailable" - } - ] -''' - -import time -import sys -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, slb_connect - -try: - from footmark.exception import SLBResponseError - - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(backend_server): - """ - get info from backend server object - :param backend_server: backend server object - :return: info of backend server - """ - return { - 'id': backend_server.server_id, - 'port': backend_server.port, - 'listener_port': backend_server.listener_port, - 'server_health_status': backend_server.server_health_status, - } - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - load_balancer_id=dict(required=True, aliases=['lb_id']), - listener_ports=dict(type='list', aliases=['ports']), - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - load_balancer_id = module.params['load_balancer_id'] - ports = module.params['listener_ports'] - result = [] - - if ports and (not isinstance(ports, list) or len(ports)) < 1: - module.fail_json(msg='backend_server_ports should be a list of backend server ports, aborting') - - try: - slb = slb_connect(module) - - # check whether server load balancer exist or not - laod_balancer = slb.describe_load_balancers(load_balancer_id=load_balancer_id) - if laod_balancer and len(laod_balancer) == 1: - if ports: - # list slb servers by port no. - for port in ports: - for backend_server in slb.describe_backend_servers_health_status( - load_balancer_id=load_balancer_id, port=port): - result.append(get_info(backend_server)) - - else: - # list all slb servers - for backend_server in slb.describe_backend_servers_health_status(load_balancer_id=load_balancer_id): - result.append(get_info(backend_server)) - - module.exit_json(changed=False, load_balancer_id=load_balancer_id, backend_servers=result) - - else: - module.fail_json(msg="Unable to list slb backend server health status, invalid load balancer id") - except Exception as e: - module.fail_json(msg="Unable to list slb backend server health status, and got an error: {0}.".format(e)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_slb_vsg_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_slb_vsg_facts.py deleted file mode 100644 index 4cab8f2e..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_slb_vsg_facts.py +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_slb_vsg_facts -version_added: "2.8" -short_description: Gather facts on virtual server group of Alibaba Cloud SLB. -description: - - This module fetches virtual server groups data from the Open API in Alibaba Cloud. -options: - load_balancer_id: - description: - - ID of server load balancer. - required: true - aliases: ["lb_id"] - vserver_group_ids: - description: - - A list of SLB vserver group ids. - required: false - aliases: ["group_ids", "ids"] - name_prefix: - description: - - Use a vritual server group name prefix to filter vserver groups. -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.9.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Note: These examples do not set authentication details, see the Alibaba Cloud Guide for details. -- name: Retrieving vsgs using slb id - ali_slb_vsg_facts: - lb_id: '{{item}}' - with_items: '{{slbs.ids}}' - -- name: Filter vsg using name_regex - ali_slb_vsg_facts: - name_prefix: 'ansible-foo' - lb_id: 'lb-cn3cn34' -''' - -RETURN = ''' -ids: - description: List ids of being fetched virtual server group. - returned: when success - type: list - sample: ["rsp-2zehblhcv", "rsp-f22c4lhcv"] -names: - description: List name of being fetched virtual server group. - returned: when success - type: list - sample: ["ansible-1", "ansible-2"] -vserver_groups: - description: - - info about the virtual server group that was created or deleted. - returned: on present - type: complex - contains: - address: - description: The IP address of the loal balancer - returned: always - type: string - sample: "47.94.26.126" - - backend_servers: - description: The load balancer's backend servers - returned: always - type: complex - contains: - port: - description: The backend server port - returned: always - type: int - sample: 22 - server_id: - description: The backend server id - returned: always - type: string - sample: "i-vqunci342" - type: - description: The backend server type, ecs or eni - returned: always - type: string - sample: "ecs" - weight: - description: The backend server weight - returned: always - type: int - sample: 100 - id: - description: The ID of the virtual server group was created. Same as vserver_group_id. - returned: always - type: string - sample: "rsp-2zehblhcv" - vserver_group_id: - description: The ID of the virtual server group was created. - returned: always - type: string - sample: "rsp-2zehblhcv" - vserver_group_name: - description: The name of the virtual server group was created. - returned: always - type: string - sample: "ansible-ali_slb_vsg" - name: - description: The name of the virtual server group was created. - returned: always - type: string - sample: "ansible-ali_slb_vsg" - tags: - description: The load balancer tags - returned: always - type: complex - sample: {} -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import SLBResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - load_balancer_id=dict(type='str', aliases=['lb_id'], required=True), - vserver_group_ids=dict(type='list', aliases=['group_ids', 'ids']), - name_prefix=dict(type='str') - )) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - vsg_ids = module.params['vserver_group_ids'] - name_prefix = module.params['name_prefix'] - - ids = [] - vsgs = [] - names = [] - - try: - slb = slb_connect(module) - groups = slb.describe_vserver_groups(**{'load_balancer_id': module.params['load_balancer_id']}) - - if groups: - for group in groups: - if vsg_ids and group.id not in vsg_ids: - continue - if name_prefix and not str(group.name).startswith(name_prefix): - continue - vsgs.append(group.read()) - ids.append(group.id) - names.append(group.name) - - module.exit_json(changed=False, vserver_groups=vsgs, ids=ids, names=names) - except Exception as e: - module.fail_json(msg=str("Unable to describe slb vserver groups, error:{0}".format(e))) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_vpc_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_vpc_facts.py deleted file mode 100644 index 39c7a109..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_vpc_facts.py +++ /dev/null @@ -1,229 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_vpc_facts -version_added: "2.8" -short_description: Gather facts on vpcs of Alibaba Cloud. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the vpc itself. - -options: - vpc_name: - description: - - (Deprecated) Name of one or more VPC that exist in your account. New option `name_prefix` instead. - aliases: ["name"] - vpc_ids: - description: - - A list of VPC IDs that exist in your account. - aliases: ["ids"] - name_prefix: - description: - - Use a VPC name prefix to filter VPCs. - cidr_prefix: - description: - - Use a VPC cidr block prefix to filter VPCs. - filters: - description: - - A dict of filters to apply. Each dict item consists of a filter key and a filter value. The filter keys can be - all of request parameters. See U(https://www.alibabacloud.com/help/doc-detail/35739.htm) for parameter details. - Filter keys can be same as request parameter name or be lower case and use underscore ("_") or dash ("-") to - connect different words in one parameter. 'VpcId' will be appended to I(vpc_ids) automatically. -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.7.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Note: These examples do not set authentication details, see the Alibaba Cloud Guide for details. - -# Gather facts about all VPCs -- ali_vpc_facts: - -# Gather facts about a particular VPC using VPC ID -- ali_vpc_facts: - vpc_ids: - - vpc-aaabbb - - vpc-123fwec - -# Gather facts about any VPC with 'is_default' and name_prefix -- ali_vpc_facts: - name_prefix: "my-vpc" - filters: - is_default: False - -# Gather facts about any VPC with cidr_prefix -- ali_vpc_facts: - cidr_prefix: "172.16" -''' - -RETURN = ''' -ids: - description: List all vpc's id after operating vpc. - returned: when success - type: list - sample: [ "vpc-2zegusms7jwd94lq7ix8o", "vpc-2ze5hrb3y5ksx5oa3a0xa" ] -vpcs: - description: Returns an array of complex objects as described below. - returned: always - type: complex - contains: - cidr_block: - description: The CIDR of the VPC - returned: always - type: string - sample: 10.0.0.0/8 - creation_time: - description: The time the VPC was created. - returned: always - type: string - sample: 2018-06-24T15:14:45Z - description: - description: The VPC description. - returned: always - type: string - sample: "my ansible vpc" - id: - description: alias of 'vpc_id'. - returned: always - type: string - sample: vpc-c2e00da5 - is_default: - description: indicates whether this is the default VPC - returned: always - type: bool - sample: false - state: - description: state of the VPC - returned: always - type: string - sample: available - tags: - description: tags attached to the VPC, includes name - returned: always - type: complex - sample: - user_cidrs: - description: The custom CIDR of the VPC - returned: always - type: list - sample: [] - vpc_id: - description: VPC resource id - returned: always - type: string - sample: vpc-c2e00da5 - vpc_name: - description: Name of the VPC - returned: always - type: string - sample: my-vpc - vrouter_id: - description: The ID of virtual router which in the VPC - returned: always - type: string - sample: available - vswitch_ids: - description: List IDs of virtual switch which in the VPC - returned: always - type: list - sample: [vsw-123cce3, vsw-34cet4v] -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import VPCResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - vpc_ids=dict(type='list', aliases=['ids']), - vpc_name=dict(aliases=['name']), - name_prefix=dict(), - cidr_prefix=dict(), - filters=dict(type='dict') - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - filters = module.params['filters'] - if not filters: - filters = {} - - vpc_ids = module.params['vpc_ids'] - if not vpc_ids: - vpc_ids = [] - for key, value in list(filters.items()): - if key in ["VpcId", "vpc_id", "vpc-id"] and value not in vpc_ids: - vpc_ids.append(value) - - name = module.params['vpc_name'] - name_prefix = module.params['name_prefix'] - cidr_prefix = module.params['cidr_prefix'] - - try: - vpcs = [] - ids = [] - while True: - if vpc_ids: - filters['vpc_id'] = vpc_ids[0] - vpc_ids.pop(0) - for vpc in vpc_connect(module).describe_vpcs(**filters): - if name and vpc.vpc_name != name: - continue - if name_prefix and not str(vpc.vpc_name).startswith(name_prefix): - continue - if cidr_prefix and not str(vpc.cidr_block).startswith(cidr_prefix): - continue - vpcs.append(vpc.read()) - ids.append(vpc.id) - if not vpc_ids: - break - - module.exit_json(changed=False, ids=ids, vpcs=vpcs) - except Exception as e: - module.fail_json(msg=str("Unable to get vpcs, error:{0}".format(e))) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_ali_vswitch_facts.py b/lib/ansible/modules/cloud/alicloud/_ali_vswitch_facts.py deleted file mode 100644 index eb437ed6..00000000 --- a/lib/ansible/modules/cloud/alicloud/_ali_vswitch_facts.py +++ /dev/null @@ -1,237 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - - -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: ali_vswitch_facts -version_added: "2.8" -short_description: Gather facts on vswitchs of Alibaba Cloud. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the vswitch itself. - -options: - vswitch_name: - description: - - (Deprecated) Name of one or more vswitch that exist in your account. New option `name_prefix` instead. - aliases: ["name", 'subnet_name'] - vswitch_ids: - description: - - A list of vswitch IDs to gather facts for. - aliases: ['subnet_ids', 'ids'] - cidr_block: - description: - - (Deprecated) The CIDR block representing the Vswitch e.g. 10.0.0.0/8. New option `cidr_prefix` instead. - name_prefix: - description: - - Use a VSwitch name prefix to filter vswitches. - cidr_prefix: - description: - - Use a VSwitch cidr block prefix to filter vswitches. - filters: - description: - - A dict of filters to apply. Each dict item consists of a filter key and a filter value. The filter keys can be - all of request parameters. See U(https://www.alibabacloud.com/help/doc-detail/35748.htm) for parameter details. - Filter keys can be same as request parameter name or be lower case and use underscores ("_") or dashes ("-") to - connect different words in one parameter. 'VSwitchId' will be appended to I(vswitch_ids) automatically. -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.7.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Note: These examples do not set authentication details, see the Alibaba Cloud Guide for details. - -# Gather facts about all VPC vswitches -- ali_vswitch_facts: - -# Gather facts about a particular VPC subnet using ID -- ali_vswitch_facts: - vswitch_ids: - - vsw-00112233 - -# Gather facts about any VPC subnet within VPC with ID vpc-abcdef00 -- ali_vswitch_facts: - filters: - vpc-id: vpc-abcdef00 - -# Gather facts about a set of VPC subnets, cidrA, cidrB and cidrC within a VPC -- ali_vswitch_facts: - cidr_prefix: "10.0." - filters: - vpc-id: vpc-abcdef00 -''' - -RETURN = ''' -ids: - description: List ids of being fetched vswtich. - returned: when success - type: list - sample: [ "vsw-2zegusms7jwd94lq7ix8o", "vsw-2ze5hrb3y5ksx5oa3a0xa" ] -vswitches: - description: Returns an array of complex objects as described below. - returned: success - type: complex - contains: - id: - description: alias of vswitch_id - returned: always - type: string - sample: vsw-b883b2c4 - cidr_block: - description: The IPv4 CIDR of the VSwitch - returned: always - type: string - sample: "10.0.0.0/16" - availability_zone: - description: Availability zone of the VSwitch - returned: always - type: string - sample: cn-beijing-a - state: - description: state of the Subnet - returned: always - type: string - sample: available - is_default: - description: indicates whether this is the default VSwitch - returned: always - type: bool - sample: false - tags: - description: tags attached to the Subnet, includes name - returned: always - type: dict - sample: {"Name": "My Subnet", "env": "staging"} - vpc_id: - description: the id of the VPC where this VSwitch exists - returned: always - type: string - sample: vpc-67236184 - available_ip_address_count: - description: number of available IPv4 addresses - returned: always - type: string - sample: 250 - vswitch_id: - description: VSwitch resource id - returned: always - type: string - sample: vsw-b883b2c4 - subnet_id: - description: alias of vswitch_id - returned: always - type: string - sample: vsw-b883b2c4 - vswitch_name: - description: VSwitch resource name - returned: always - type: string - sample: my-vsw - creation_time: - description: The time the VSwitch was created. - returned: always - type: string - sample: 2018-06-24T15:14:45Z -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import VPCResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - vswitch_name=dict(aliases=['name', 'subnet_name']), - cidr_block=dict(), - name_prefix=dict(), - cidr_prefix=dict(), - vswitch_ids=dict(type='list', aliases=['ids', 'subnet_ids']), - filters=dict(type='dict') - ) - ) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for this module.") - - filters = module.params['filters'] - if not filters: - filters = {} - - vswitch_ids = module.params['vswitch_ids'] - if not vswitch_ids: - vswitch_ids = [] - for key, value in list(filters.items()): - if key in ["VSwitchId", "vswitch_id", "vswitch-id"] and value not in vswitch_ids: - vswitch_ids.append(value) - - name = module.params['vswitch_name'] - cidr_block = module.params['cidr_block'] - name_prefix = module.params['name_prefix'] - cidr_prefix = module.params['cidr_prefix'] - - try: - vswitches = [] - ids = [] - while True: - if vswitch_ids: - filters['vswitch_id'] = vswitch_ids[0] - vswitch_ids.pop(0) - for vsw in vpc_connect(module).describe_vswitches(**filters): - if name and vsw.vswitch_name != name: - continue - if cidr_block and vsw.cidr_block != cidr_block: - continue - if name_prefix and not str(vsw.vswitch_name).startswith(name_prefix): - continue - if cidr_prefix and not str(vsw.cidr_block).startswith(cidr_prefix): - continue - vswitches.append(vsw.read()) - ids.append(vsw.id) - if not vswitch_ids: - break - - module.exit_json(changed=False, ids=ids, vswitches=vswitches) - except Exception as e: - module.fail_json(msg=str("Unable to get vswitches, error:{0}".format(e))) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_bucket.py b/lib/ansible/modules/cloud/alicloud/_alicloud_bucket.py deleted file mode 100644 index 08dae997..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_bucket.py +++ /dev/null @@ -1,215 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_bucket -version_added: "1.0.9" -short_description: Create/Delete/Retrieve Bucket. -description: - - This module allows the user to manage OSS buckets. Includes support for creating, deleting and retrieving buckets. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_oss_bucket) instead. -options: - state: - description: - - Create or delete the OSS bucket. List all buckets that has the prefix of 'bucket' value. - default: 'present' - choices: [ 'present', 'absent', 'list'] - bucket: - description: - - Bucket name. - required: true - aliases: [ 'name' ] - permission: - description: - - This option lets the user set the canned permissions on the bucket that are created. - default: 'private' - choices: [ 'private', 'public-read', 'public-read-write' ] - aliases: [ 'acl' ] -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" -''' - -EXAMPLES = ''' -# -# provisioning new oss bucket -# - -# basic provisioning example to create bucket -- name: create oss bucket - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hangzhou - state: present - bucket: bucketname - permission: public-read-write - tasks: - - name: create oss bucket - alicloud_bucket: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - state: '{{ state }}' - bucket: '{{ bucket }}' - permission: '{{ permission }}' - register: result - - debug: var=result - -# basic provisioning example to delete bucket -- name: delete oss bucket - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hangzhou - state: absent - bucket: bucketname - tasks: - - name: delete oss bucket - alicloud_bucket: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - state: '{{ state }}' - bucket: '{{ bucket }}' - register: result - - debug: var=result -''' - -RETURN = ''' -changed: - description: current operation whether changed the resource - returned: when success - type: bool - sample: true -bucket: - description: the bucket's headers after create bucket or update its acl - returned: on present - type: dict - sample: { - "id": "xiaozhubucket", - "location": "oss-cn-beijing", - "name": "xiaozhubucket", - "permission": "public-read" - } -buckets: - description: the list all buckets that has the prefix of 'bucket' value in the specified region - returned: when list - type: list - sample: [ - { - "id": "xiaozhubucket", - "location": "oss-cn-beijing", - "name": "xiaozhubucket", - "permission": "public-read" - }, - { - "id": "xiaozhubucket-2", - "location": "oss-cn-beijing", - "name": "xiaozhubucket-2", - "permission": "private" - } - ] -''' - -# import module snippets -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_oss import oss_bucket_argument_spec, oss_bucket_connect, oss_service_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError, OSSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_bucket(bucket): - return {'id': bucket.id, 'name': bucket.name, 'permission': bucket.acl, 'location': bucket.location} - - -def main(): - argument_spec = oss_bucket_argument_spec() - argument_spec.update( - dict( - state=dict(required=True, choices=['present', 'absent', 'list']), - permission=dict(default='private', choices=['private', 'public-read', 'public-read-write'], aliases=['acl']), - bucket=dict(required=True, aliases=["name"]), - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for the module alicloud_bucket.") - - oss_bucket = oss_bucket_connect(module) - state = module.params['state'] - permission = module.params['permission'] - - if state == 'present': - try: - if oss_bucket.is_exist(): - result = oss_bucket.put_acl(permission=permission) - else: - result = oss_bucket.create(permission=permission) - module.exit_json(changed=True, bucket=get_bucket(result)) - except Exception as e: - module.fail_json(msg="Unable to put bucket or set acl for it, and got an error: {0}.".format(e)) - - elif state == 'absent': - try: - oss_bucket.delete() - module.exit_json(changed=True) - except Exception as e: - module.fail_json(msg="Unable to delete bucket, and got an error: {0}.".format(e)) - - else: - try: - oss_service = oss_service_connect(module) - keys = oss_service.list_buckets(prefix=module.params['bucket'], max_keys=200) - - buckets = [] - for name in keys: - module.params['bucket'] = name - buckets.append(get_bucket(oss_bucket_connect(module))) - - module.exit_json(changed=False, buckets=buckets) - except Exception as e: - module.fail_json(msg="Unable to list buckets, and got an error: {0}.".format(e)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_bucket_object.py b/lib/ansible/modules/cloud/alicloud/_alicloud_bucket_object.py deleted file mode 100644 index 662dc702..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_bucket_object.py +++ /dev/null @@ -1,383 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_bucket_object -version_added: "1.0.9" -short_description: Manage object in OSS -description: - - This module allows the user to manage OSS objects within bucket. Includes support for uploading and downloading - objects, retrieving object keys. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_oss_object) instead. -options: - mode: - description: - - Switches the module behaviour between put (upload), get (download), list (list objects) and delete (delete object). - required: true - choices: ['get', 'put', 'delete', 'list'] - bucket: - description: - - Bucket name. - required: true - permission: - description: - - This option lets the user set the canned permissions on the objects that are put. The permissions that - can be set are 'private', 'public-read', 'public-read-write'. - default: 'private' - choices: [ 'private', 'public-read', 'public-read-write' ] - aliases: [ 'acl' ] - headers: - description: - - Custom headers for PUT or GET operation, as a dictionary of 'key=value' and 'key=value,key=value'. - overwrite: - description: - - Force overwrite specified object content when putting object. - If it is true/false, object will be normal/appendable. Appendable Object can be convert to Noraml by setting - overwrite to true, but conversely, it won't be work. - default: False - type: bool - content: - description: - - The object content that will be upload. It is conflict with 'file_name' when mode is 'put'. - file_name: - description: - - The name of file that used to upload or download object. - aliases: [ "file" ] - object: - description: - - Name to object after uploaded to bucket - required: true - aliases: [ 'key', 'object_name' ] - byte_range: - description: - - The range of object content that would be download. - Its format like 1-100 that indicates range from one to hundred bytes of object. - aliases: [ 'range' ] -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" -''' - -EXAMPLES = ''' - -# basic provisioning example to upload a content -- name: simple upload to bucket - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hangzhou - mode: put - bucket: bucketname - content: 'Hello world! I come from alicloud.' - object: 'remote_file.txt' - headers: - Content-Type: 'text/html' - Content-Encoding: md5 - tasks: - - name: simple upload to bucket - alicloud_bucket_object: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - mode: '{{ mode }}' - bucket: '{{ bucket }}' - content: '{{ content }}' - headers: '{{ headers }}' - register: result - - debug: var=result - -# basic provisioning example to upload a file -- name: simple upload to bucket - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hangzhou - mode: put - bucket: bucketname - file_name: 'test_oss.yml' - object: 'remote_file.txt' - headers: - Content-Type: 'text/html' - Content-Encoding: md5 - tasks: - - name: simple upload to bucket - alicloud_bucket_object: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - mode: '{{ mode }}' - file_name: '{{ file_name }}' - content: '{{ content }}' - headers: '{{ headers }}' - register: result - - debug: var=result - -# basic provisioning example to download a object -- name: simple upload to bucket - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hangzhou - mode: get - bucket: bucketname - download: 'my_test.json' - byte_range: 0-100 - object: 'remote_file.txt' - headers: - Content-Type: 'text/html' - Content-Encoding: md5 - tasks: - - name: simple upload to bucket - alicloud_bucket_object: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - mode: '{{ mode }}' - file_name: '{{ download }}' - byte_range: '{{ byte_range }}' - content: '{{ content }}' - headers: '{{ headers }}' - register: result - - debug: var=result - -# basic provisioning example to list bucket objects -- name: list bucket objects - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hangzhou - mode: list - bucket: bucketname - tasks: - - name: list bucket objects - alicloud_bucket_object: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - mode: '{{ mode }}' - bucket: '{{ bucket }}' - register: list_result - - debug: var=list_result - -# basic provisioning example to delete bucket object -- name: delete bucket objects - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hangzhou - mode: delete - bucket: bucketname - object: 'remote_file.txt' - tasks: - - name: delete bucket objects - alicloud_bucket_object: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - mode: '{{ mode }}' - bucket: '{{ bucket }}' - object: '{{ object }}' - register: delete_object_result - - debug: var=delete_object_result -''' - -RETURN = ''' -changed: - description: current operation whether changed the resource - returned: when success - type: bool - sample: true -key: - description: the name of oss object - returned: expect list - type: bool - sample: true -object: - description: the object's information - returned: on put or get - type: dict - sample: { - "etag": "A57B09D4A76BCF486DDD755900000000", - "key": "newobject-2", - "last_modified": "2017-07-24 19:43:41", - "next_append_position": 11, - "size": "11 B", - "storage_class": "Standard", - "type": "Appendable" - } -objects: - description: the list all objects that has the prefix of 'object' value in the specified bucket - returned: when list - type: list - sample: [ - { - "etag": "54739B1D5AEBFD38C83356D8A8A3EDFC", - "key": "newobject-1", - "last_modified": "2017-07-24 19:42:46", - "size": "2788 B", - "storage_class": "Standard", - "type": "Normal" - }, - { - "etag": "EB8BDADA044D58D58CDE755900000000", - "key": "newobject-2", - "last_modified": "2017-07-24 19:48:28", - "next_append_position": 5569, - "size": "5569 B", - "storage_class": "Standard", - "type": "Appendable" - } - ] -''' -# import module snippets -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_oss import oss_bucket_argument_spec, oss_bucket_connect -import time - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError, OSSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_object_info(obj): - result = {'key': obj.key, 'last_modified': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(obj.last_modified)), - 'etag': obj.etag, 'type': obj.type, 'size': str(obj.size) + ' B', 'storage_class': obj.storage_class} - - if obj.type == 'Appendable': - result['next_append_position'] = obj.size - - return result - - -def main(): - argument_spec = oss_bucket_argument_spec() - argument_spec.update(dict( - bucket=dict(type='str', required=True), - mode=dict(type='str', required=True, choices=['put', 'get', 'list', 'delete']), - permission=dict(type='str', default='private', choices=['private', 'public-read', 'public-read-write']), - headers=dict(type='dict'), - overwrite=dict(type='bool', default=False), - content=dict(type='str'), - file_name=dict(type='str', aliases=['file']), - object=dict(type='str', aliases=['key', 'object_name']), - byte_range=dict(type='str', aliases=['range']) - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for the module alicloud_bucket_object.") - - oss_bucket = oss_bucket_connect(module) - mode = module.params['mode'] - file_name = module.params['file_name'] - object_key = module.params['object'] - headers = module.params['headers'] - - changed = False - - if mode == 'put': - content = module.params['content'] - if content and file_name: - module.fail_json(msg="'content' and 'file_name' only one can be specified when mode is put.") - - overwrite = module.params['overwrite'] - permission = module.params['permission'] - - try: - if content: - oss_bucket.put_object(object_key, content, overwrite, headers=headers) - changed = True - elif file_name: - oss_bucket.put_object_from_file(object_key, file_name, overwrite, headers=headers) - changed = True - elif oss_bucket.is_object_exist(object_key): - if permission: - oss_bucket.put_object_acl(object_key, permission) - changed = True - if headers: - oss_bucket.update_object_headers(object_key, headers) - changed = True - module.exit_json(changed=changed, key=object_key, object=get_object_info(oss_bucket.get_object_info(object_key))) - except Exception as e: - module.fail_json(msg="Unable to upload an object {0} or " - "modify its permission and headers, and got an error: {1}".format(object_key, e)) - - elif mode == 'get': - byte_range = module.params['byte_range'] - try: - if file_name: - oss_bucket.get_object_to_file(object_key, file_name, byte_range=byte_range, headers=headers) - else: - module.fail_json(msg="'file_name' must be specified when mode is get.") - module.exit_json(changed=changed, key=object_key, object=get_object_info(oss_bucket.get_object_info(object_key))) - except Exception as e: - module.fail_json(msg="Unable to download object {0}, and got an error: {1}".format(object_key, e)) - - elif mode == 'list': - objects = [] - max_keys = 500 - try: - while True: - results = oss_bucket.list_objects(prefix=object_key, max_keys=max_keys) - for obj in results: - objects.append(get_object_info(obj)) - - if len(results) < max_keys: - break - module.exit_json(changed=False, objects=objects) - except Exception as e: - module.fail_json(msg="Unable to retrieve all objects, and got an error: {0}".format(e)) - - else: - try: - oss_bucket.delete_object(object_key) - module.exit_json(changed=changed, key=object_key) - except Exception as e: - module.fail_json(msg="Unable to delete an object {0}, and got an error: {1}".format(object_key, e)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_disk.py b/lib/ansible/modules/cloud/alicloud/_alicloud_disk.py deleted file mode 100644 index a2193433..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_disk.py +++ /dev/null @@ -1,432 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_disk -version_added: "1.0.9" -short_description: Create, Attach, Detach or Delete a disk in Alicloud ECS -description: - - Creates and delete a ECS disk.starts, stops, restarts or terminates ecs instances. - - Attach a disk to an ecs instance or detach a disk from it. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_disk) instead. -options: - state: - description: - - The state of operating ecs disk. - default: 'present' - choices: - - ['present', 'absent'] - alicloud_zone: - description: - - Aliyun availability zone ID which to launch the disk - required: true - aliases: [ 'zone_id', 'zone' ] - disk_name: - description: - - The name of ECS disk, which is a string of 2 to 128 Chinese or English characters. It must begin with an - uppercase/lowercase letter or a Chinese character and can contain numerals, ".", "_", or "-". - It cannot begin with http:// or https://. - aliases: [ 'name' ] - description: - description: - - The description of ECS disk, which is a string of 2 to 256 characters. It cannot begin with http:// or https://. - aliases: [ 'disk_description' ] - disk_category: - description: - - The category to apply to the disk. - default: 'cloud' - aliases: ['volume_type', 'disk_type'] - choices: ['cloud', 'cloud_efficiency', 'cloud_ssd'] - size: - description: - - Size of disk (in GB) to create. - 'cloud' valid value is 5~2000; 'cloud_efficiency' or 'cloud_ssd' valid value is 20~32768. - aliases: ['volume_size', 'disk_size'] - snapshot_id: - description: - - Snapshot ID on which to base the data disk. - If this parameter is specified, the value of 'size' will be ignored. The actual created disk size is the specified snapshot's size. - aliases: ['snapshot'] - disk_tags: - description: - - A list of hash/dictionaries of instance tags, ['{"tag_key":"value", "tag_value":"value"}'], - tag_key must be not null when tag_value isn't null. - aliases: ['tags'] - instance_id: - description: - - Ecs instance ID is used to attach the disk. The specified instance and disk must be in the same zone. - If it is null or not be specified, the attached disk will be detach from instance. - aliases: ['instance'] - disk_id: - description: - - Disk ID is used to attach an existing disk (required instance_id), detach or remove an existing disk. - required: true - aliases: ['vol_id', 'id'] - delete_with_instance: - description: - - When set to true, the disk will be released along with terminating ECS instance. - When mark instance's attribution 'OperationLocks' as "LockReason":"security", - its value will be ignored and disk will be released along with terminating ECS instance. - aliases: ['delete_on_termination'] - type: bool -notes: - - At present, when attach disk, system allocates automatically disk device according to default order from /dev/xvdb to /dev/xvdz. -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" - -''' - -EXAMPLES = ''' -# -# Provisioning new disk -# - -# Basic provisioning example create a disk -- name: create disk - hosts: localhost - connection: local - vars: - alicloud_access_key: xxxxxxxxxx - alicloud_secret_key: xxxxxxxxxx - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-b - size: 20 - state: present - tasks: - - name: create disk - alicloud_disk: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - alicloud_zone: '{{ alicloud_zone }}' - size: '{{ size }}' - state: '{{ state }}' - register: result - - debug: var=result - -# Advanced example with tagging and snapshot -- name: create disk - hosts: localhost - connection: local - vars: - alicloud_access_key: xxxxxxxxxx - alicloud_secret_key: xxxxxxxxxx - alicloud_region: cn-hongkong - alicloud_zone: cn-hongkong-b - disk_name: disk_1 - description: data disk_1 - size: 20 - snapshot_id: xxxxxxxxxx - disk_category: cloud_ssd - state: present - tasks: - - name: create disk - alicloud_disk: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - alicloud_zone: '{{ alicloud_zone }}' - disk_name: '{{ disk_name }}' - description: '{{ description }}' - size: '{{ size }}' - snapshot_id: '{{ snapshot_id }}' - disk_category: '{{ disk_category }}' - state: '{{ state }}' - register: result - - debug: var=result - - -# Example to attach disk to an instance -- name: attach disk to instance - hosts: localhost - connection: local - vars: - state: present - alicloud_access_key: xxxxxxxxxx - alicloud_secret_key: xxxxxxxxxx - alicloud_region: us-west-1 - instance_id: xxxxxxxxxx - disk_id: xxxxxxxxxx - delete_with_instance: no - tasks: - - name: Attach Disk to instance - alicloud_disk: - state: '{{ state }}' - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - instance_id: '{{ instance_id }}' - disk_id: '{{ disk_id }}' - delete_with_instance: '{{ delete_with_instance }}' - register: result - - debug: var=result - - -# Example to detach disk from instance -- name: detach disk - hosts: localhost - connection: local - vars: - alicloud_access_key: xxxxxxxxxx - alicloud_secret_key: xxxxxxxxxx - alicloud_region: us-west-1 - disk_id: xxxxxxxxxx - state: present - tasks: - - name: detach disk - alicloud_disk: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - id: '{{ disk_id }}' - state: '{{ state }}' - register: result - - debug: var=result - - -# Example to delete disk -- name: detach disk - hosts: localhost - connection: local - vars: - alicloud_access_key: xxxxxxxxxx - alicloud_secret_key: xxxxxxxxxx - alicloud_region: us-west-1 - disk_id: xxxxxxxxxx - state: absent - tasks: - - name: detach disk - alicloud_disk: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - disk_id: '{{ disk_id }}' - state: '{{ state }}' - register: result - - debug: var=result -''' - -RETURN = ''' -device: - description: device name of attached disk - returned: except on delete - type: string - sample: "/def/xdva" -disk_category: - description: the category of disk - returned: except on delete - type: string - sample: "cloud" -disk_id: - description: the id of disk - returned: when success - type: string - sample: "d-2zecn395ktww53aylfw6 " -disk_status: - description: the current status of disk - returned: except on delete - type: string - sample: "available" -disk: - description: Details about the ecs disk that was created. - returned: except on delete - type: dict - sample: { - "category": "cloud_efficiency", - "description": "travis-ansible-instance", - "device": "", - "disk_name": "travis-ansible-instance", - "id": "d-2ze9yw0a1sw9neyx8t24", - "instance_id": "", - "launch_time": "2017-06-19T03:19:30Z", - "region_id": "cn-beijing", - "size": 40, - "status": "available", - "type": "data", - "zone_id": "cn-beijing-a" - } -instance_id: - description: the instance id which attached disk - returned: on attach - type: string - sample: "i-i2rnfnenfnds" -''' - -import time -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, ecs_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_disk_detail(disk): - """ - Method call to attach disk - - :param module: Ansible module object - :param disk_id: ID of Disk to Describe - :return: return id, status and object of disk - """ - - return {'id': disk.disk_id, - 'category': disk.category, - 'size': disk.size, - 'device': disk.device, - 'zone_id': disk.zone_id, - 'region_id': disk.region_id, - 'launch_time': disk.creation_time, - 'disk_name': disk.disk_name, - 'description': disk.description, - 'status': disk.status, - 'type': disk.type, - 'instance_id': disk.instance_id - } - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - group_id=dict(), - alicloud_zone=dict(aliases=['zone_id', 'zone']), - state=dict(default='present', choices=['present', 'absent']), - disk_id=dict(aliases=['vol_id', 'id']), - disk_name=dict(aliases=['name']), - disk_category=dict(aliases=['disk_type', 'volume_type']), - size=dict(aliases=['disk_size', 'volume_size']), - disk_tags=dict(type='list', aliases=['tags']), - snapshot_id=dict(aliases=['snapshot']), - description=dict(aliases=['disk_description']), - instance_id=dict(aliases=['instance']), - delete_with_instance=dict(aliases=['delete_on_termination'], default=None) - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - - if not HAS_FOOTMARK: - module.fail_json(msg="footmark required for the module alicloud_disk.") - - ecs = ecs_connect(module) - state = module.params['state'] - - instance_id = module.params['instance_id'] - disk_id = module.params['disk_id'] - zone_id = module.params['alicloud_zone'] - disk_name = module.params['disk_name'] - delete_with_instance = module.params['delete_with_instance'] - description = module.params['description'] - - changed = False - current_disk = None - - try: - if disk_id: - disks = ecs.get_all_volumes(zone_id=zone_id, volume_ids=[disk_id]) - if disks and len(disks) == 1: - current_disk = disks[0] - elif disk_name: - disks = ecs.get_all_volumes(zone_id=zone_id, volume_name=disk_name) - if disks: - if len(disks) == 1: - current_disk = disks[0] - else: - disk_ids = [] - for d in disks: - disk_ids.append(d.id) - module.fail_json(msg="There is too many disks match name '{0}', " - "please use disk_id or a new disk_name to specify a unique disk." - "Matched disk ids are: {1}".format(disk_name, disk_ids)) - except ECSResponseError as e: - module.fail_json(msg='Error in get_all_volumes: %s' % str(e)) - - if state == 'absent': - if not current_disk: - module.fail_json(msg="Please use disk_id or disk_name to specify one disk for detaching or deleting.") - if instance_id: - try: - changed = current_disk.detach(instance_id) - module.exit_json(changed=changed, disk_id=current_disk.id, disk_category=current_disk.category, - disk_status=current_disk.status, instance_id=instance_id, - disk=get_disk_detail(current_disk)) - except Exception as e: - module.fail_json(msg='Detaching disk {0} is failed, error: {1}'.format(current_disk.id, e)) - - try: - changed = current_disk.delete() - module.exit_json(changed=changed) - except Exception as e: - module.fail_json(msg='Deleting disk {0} is failed, error: {1}'.format(current_disk.id, e)) - - # state == present - if not current_disk: - disk_category = module.params['disk_category'] - size = module.params['size'] - disk_tags = module.params['disk_tags'] - snapshot_id = module.params['snapshot_id'] - client_token = "Ansible-Alicloud-%s-%s" % (hash(str(module.params)), str(time.time())) - try: - current_disk = ecs.create_disk(zone_id=zone_id, disk_name=disk_name, - description=description, disk_category=disk_category, size=size, - disk_tags=disk_tags, snapshot_id=snapshot_id, client_token=client_token) - changed = True - except Exception as e: - module.fail_json(msg='Creating a new disk is failed, error: {0}'.format(e)) - - else: - try: - if current_disk.name != disk_name \ - or current_disk.description != description \ - or current_disk.delete_with_instance != delete_with_instance: - changed = current_disk.modify(disk_name=disk_name, description=description, - delete_with_instance=delete_with_instance) - except Exception as e: - module.fail_json(msg='Updating disk {0} attribute is failed, error: {1}'.format(current_disk.id, e)) - - if instance_id and current_disk and str(current_disk.status).lower() == "available": - try: - changed = current_disk.attach(instance_id=instance_id, delete_with_instance=delete_with_instance) - except Exception as e: - module.fail_json( - msg='Attaching disk {0} to instance {1} is failed, error: {2}'.format(current_disk.id, instance_id, e)) - - module.exit_json(changed=changed, disk_id=current_disk.id, disk_category=current_disk.category, - disk_status=current_disk.status, instance_id=instance_id, disk=get_disk_detail(current_disk)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_disk_facts.py b/lib/ansible/modules/cloud/alicloud/_alicloud_disk_facts.py deleted file mode 100644 index 33b524cb..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_disk_facts.py +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_disk_facts -version_added: "1.0.9" -short_description: Gather facts on disks of Alibaba Cloud ECS. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the ECS disk itself. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_disk_facts) instead. -options: - alicloud_zone: - description: - - Aliyun availability zone ID in which to launch the disk - aliases: ['zone_id', 'zone' ] - disk_names: - description: - - A list of ECS disk names. - aliases: [ "names"] - disk_ids: - description: - - A list of ECS disk ids. - aliases: ["ids"] -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Fetch disk details according to setting different filters -- name: fetch disk details example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-a - - tasks: - - name: Find all disks in the specified region - alicloud_disk_facts: - alicloud_zone: "{{ alicloud_zone }}" - alicloud_region: "{{ alicloud_region }}" - register: all_disks - - name: Find all disks based on the specified ids - alicloud_disk_facts: - alicloud_zone: "{{ alicloud_zone }}" - alicloud_region: "{{ alicloud_region }}" - disk_ids: - - "d-2ze8ohezcyvm4omrabud" - - "d-2zeakwizkdjdu4q4lfco" - register: disks_by_ids - - name: Find all disks based on the specified names/name-prefixes - alicloud_disk_facts: - alicloud_zone: "{{ alicloud_zone }}" - alicloud_region: "{{ alicloud_region }}" - disk_ids: - - "d-2ze8ohezcyvm4omrabud" - - "d-2zeakwizkdjdu4q4lfco" - disk_names: - - "test1" - register: disks_by_names - -''' - -RETURN = ''' -disk_ids: - description: List all disk's id after operating ecs disk. - returned: when success - type: list - sample: ["d-2ze8ohezcyvm4omrabud","d-2zeakwizkdjdu4q4lfco"] -disks: - description: Details about the ecs disks that were created. - returned: when success - type: list - sample: [ - { - "attached_time": "2017-08-15T06:47:55Z", - "category": "cloud_efficiency", - "creation_time": "2017-08-15T06:47:45Z", - "delete_auto_snapshot": false, - "delete_with_instance": true, - "description": "helloworld", - "detached_time": "", - "device": "/dev/xvda", - "disk_charge_type": "PostPaid", - "enable_auto_snapshot": true, - "encrypted": false, - "id": "d-2ze8ohezcyvm4omrabud", - "image_id": "ubuntu_140405_32_40G_cloudinit_20161115.vhd", - "instance_id": "i-2zegc3s8ihxq2pcysekk", - "name": "test1", - "operation_locks": { - "operation_lock": [] - }, - "portable": false, - "product_code": "", - "region_id": "cn-beijing", - "size": 40, - "snapshop_id": "", - "status": "in_use", - "type": "system", - "zone_id": "cn-beijing-a" - }, - { - "attached_time": "2017-08-13T06:57:37Z", - "category": "cloud_efficiency", - "creation_time": "2017-08-13T06:57:30Z", - "delete_auto_snapshot": false, - "delete_with_instance": true, - "description": "", - "detached_time": "", - "device": "/dev/xvda", - "disk_charge_type": "PostPaid", - "enable_auto_snapshot": true, - "encrypted": false, - "id": "d-2zeakwizkdjdu4q4lfco", - "image_id": "ubuntu_140405_64_40G_cloudinit_20161115.vhd", - "instance_id": "i-2zeenj8meljkoi85lz3c", - "name": "test2", - "operation_locks": { - "operation_lock": [] - }, - "portable": false, - "product_code": "", - "region_id": "cn-beijing", - "size": 40, - "snapshop_id": "", - "status": "in_use", - "type": "system", - "zone_id": "cn-beijing-a" - } -] -total: - description: The number of all disks after operating ecs disk. - returned: when success - type: int - sample: 2 -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, ecs_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_disk_info(disk): - """ - Retrieves disk information from an disk - ID and returns it as a dictionary - """ - return { - 'id': disk.id, - 'region_id': disk.region_id, - 'zone_id': disk.zone_id, - 'status': disk.status, - 'name': disk.disk_name, - 'description': disk.description, - 'type': disk.type, - 'category': disk.category, - 'encrypted': disk.encrypted, - 'size': disk.size, - 'image_id': disk.image_id, - 'snapshop_id': disk.source_snapshot_id, - 'product_code': disk.product_code, - 'portable': disk.portable, - 'operation_locks': disk.operation_locks, - 'instance_id': disk.instance_id, - "device": disk.device, - "delete_with_instance": disk.delete_with_instance, - "delete_auto_snapshot": disk.delete_auto_snapshot, - "enable_auto_snapshot": disk.enable_auto_snapshot, - "creation_time": disk.creation_time, - "attached_time": disk.attached_time, - "detached_time": disk.detached_time, - "disk_charge_type": disk.disk_charge_type, - } - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - alicloud_zone=dict(aliases=['zone_id', 'zone']), - disk_ids=dict(type='list', aliases=['ids']), - disk_names=dict(type='list', aliases=['names']), - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for this module') - - ecs = ecs_connect(module) - - disks = [] - disk_ids = [] - ids = module.params['disk_ids'] - names = module.params['disk_names'] - zone_id = module.params['alicloud_zone'] - if ids and (not isinstance(ids, list) or len(ids)) < 1: - module.fail_json(msg='disk_ids should be a list of disk id, aborting') - - if names and (not isinstance(names, list) or len(names)) < 1: - module.fail_json(msg='disk_names should be a list of disk name, aborting') - - if names: - for name in names: - for disk in ecs.get_all_volumes(zone_id=zone_id, volume_ids=ids, volume_name=name): - disks.append(get_disk_info(disk)) - disk_ids.append(disk.id) - else: - for disk in ecs.get_all_volumes(zone_id=zone_id, volume_ids=ids): - disks.append(get_disk_info(disk)) - disk_ids.append(disk.id) - - module.exit_json(changed=False, disk_ids=disk_ids, disks=disks, total=len(disks)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_eip.py b/lib/ansible/modules/cloud/alicloud/_alicloud_eip.py deleted file mode 100644 index e0fb5b51..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_eip.py +++ /dev/null @@ -1,265 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'state': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: alicloud_eip -version_added: "1.0.9" -short_description: Create eip address and bind it to ECS or SLB instance. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix 'ali' will be more concise - alternative: Use M(ali_eip) instead -description: - - Create and release an elastic IP address - Associate/disassociate an EIP with ECS or SLB instance -options: - state: - description: - - state for operating elastic IP address - choices: ['present', 'absent'] - default: present - bandwidth: - description: - - Maximum outgoing bandwidth to the EIP, measured in Mbps (Mega bit per second) - default: 5 - internet_charge_type: - description: - - Internet charge type of ECS instance - choices: [ 'PayByBandwidth', 'PayByTraffic'] - default: 'PayByBandwidth' - ip_address: - description: - - The IP address of a previously created EIP. A new EIP will be allocated if it is not specified. - - If present and instance_id is specified, the EIP is associated with the instance. - - If absent and instance_id is specified, the EIP is disassociated from the instance. - aliases: ['ip'] - instance_id: - description: - - The id of the device for the EIP. Can be an ECS or SLB Instance id - aliases: ['device_id'] -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" -""" - -EXAMPLES = """ -# provide some examples to manage eip addresses -- name: requesting eip - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hongkong - internet_charge_type: PayByTraffic - bandwidth: 5 - instance_id: i-23dsefwfv332 - tasks: - - name: allocating an eip - alicloud_eip: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - internet_charge_type: '{{ internet_charge_type }}' - bandwidth: '{{ bandwidth }}' - state: present - register: new_eip - - - name: associate the created EIP with an ECS instance - alicloud_eip: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - ip_address: '{{ new_eip.ip_address }}' - instance_id: '{{ instance_id }}' - state: present - - - name: disassociate the created EIP with an ECS instance - alicloud_eip: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - ip_address: '{{ new_eip.ip_address }}' - instance_id: '{{ instance_id }}' - state: absent - - - name: disassociate the created EIP with an ECS instance - alicloud_eip: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - ip_address: '{{ new_eip.ip_address }}' - state: absent - -""" -RETURN = ''' -ip_address: - description: IP address of the allocated EIP - returned: when present - type: string - sample: "123.56.0.206" -allocation_id: - description: ID of the allocated EIP - returned: when present - type: string - sample: "eip-25877c70x" -instance_id: - description: ID of the associated device - returned: when present - type: string - sample: "i-aex25877c70x" -eip: - description: Details about the allocated EIP - returned: when present - type: dict - sample: { - "allocation_time": "2017-11-13T06:32:50Z", - "bandwidth": "7", - "charge_type": "PostPaid", - "id": "eip-gw8wkbxtnl3mh2orfpwm6", - "instance_id": "", - "instance_type": "", - "internet_charge_type": "PayByTraffic", - "ip_address": "47.91.89.172", - "operation_locks": { - "lock_reason": [] - }, - "region_id": "eu-central-1", - "status": "Available" - } -''' - -import time -from footmark.exception import VPCResponseError -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, ecs_connect, vpc_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_eip(eip_obj): - - if eip_obj: - return { - "id": eip_obj.id, - "allocation_time": eip_obj.allocation_time, - "bandwidth": eip_obj.bandwidth, - "instance_id": eip_obj.instance_id, - "instance_type": eip_obj.instance_type, - "internet_charge_type": eip_obj.internet_charge_type, - "ip_address": eip_obj.ip_address, - "operation_locks": eip_obj.operation_locks, - "region_id": eip_obj.region_id, - "status": eip_obj.status, - "charge_type": eip_obj.charge_type - } - return None - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - state=dict(type='str', default='present', choices=['present', 'absent']), - ip_address=dict(type='str', aliases=['ip']), - instance_id=dict(type='str', aliases=['device_id']), - internet_charge_type=dict(type='str', default='PayByBandwidth', choices=['PayByTraffic', 'PayByBandwidth']), - bandwidth=dict(type='int', default=5) - - )) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for the module alicloud_eip.") - module = AnsibleModule(argument_spec=argument_spec) - - vpc = vpc_connect(module) - - # set values - state = module.params['state'] - instance_id = module.params['instance_id'] - internet_charge_type = module.params['internet_charge_type'] - ip_address = module.params['ip_address'] - bandwidth = module.params['bandwidth'] - - current = None - changed = False - if ip_address: - eips = vpc.get_all_eip_addresses(ip_address=ip_address) - if eips and len(eips) > 0: - current = eips[0] - - if state == 'present': - if not current: - try: - client_token = "Ansible-Alicloud-%s-%s" % (hash(str(module.params)), str(time.time())) - current = vpc.allocate_eip_address(bandwidth=bandwidth, internet_charge_type=internet_charge_type, - client_token=client_token) - changed = True - except VPCResponseError as e: - module.fail_json(msg='Unable to allocate an eip address, error: {0}'.format(e)) - - if bandwidth > 0 and bandwidth != int(current.bandwidth): - try: - changed = current.modify(bandwidth=bandwidth) - except Exception as e: - module.fail_json(msg="Modify EIP bandwidth failed. Error: {0}".format(e)) - - if instance_id and current.status == 'Available': - try: - changed = current.associate(instance_id=instance_id) - except Exception as e: - module.fail_json(msg="Associate EIP with instance {0} failed. Error: {1}".format(instance_id, e)) - module.exit_json(changed=changed, ip_address=current.ip_address, allocation_id=current.id, - instance_id=current.instance_id, eip=get_eip(current)) - else: - if instance_id: - try: - changed = current.disassociate(instance_id=instance_id) - module.exit_json(changed=changed, ip_address=current.ip_address, allocation_d=current.id, eip=get_eip(current)) - except Exception as e: - module.fail_json(msg="Disassociate EIP with instance {0} failed. Error: {1}".format(instance_id, e)) - - #release - try: - changed = current.release() - except Exception as e: - module.fail_json(msg="Disassociate EIP with instance {0} failed. Error: {1}".format(instance_id, e)) - module.exit_json(changed=changed) - - -if __name__ == "__main__": - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_ess_configuration.py b/lib/ansible/modules/cloud/alicloud/_alicloud_ess_configuration.py deleted file mode 100644 index 9ea59465..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_ess_configuration.py +++ /dev/null @@ -1,353 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_ess_configuration -version_added: "1.0.9" -short_description: Create or Terminate an scaling configuration in ESS. -description: - - Scaling configuration defines the configuration of ECS instances used for Auto Scaling. - When adding ECS instances to a scaling group, Auto Scaling creates the ECS instances according to the scaling configuration. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_ess_configuration) instead. -options: - state: - description: - - The state of the scaling configuration after operating. - default: 'present' - choices: [ 'present', 'active', 'inactive', 'absent' ] - name: - description: - - The name of scaling configuration. The name must contain 2-40 English or Chinese characters, - and start with a number, a letter in upper or lower case or a Chinese character. - The name can contain numbers, "_", "-" or ".". Default to configuration Id. - aliases: ['configuration_name' ] - image_id: - description: - - Image ID used to scale ECS instances. Required when C(state=present). - aliases: [ 'image' ] - instance_type: - description: - - Instance type used to scale ECS instances. Required when C(state=present). - aliases: [ 'type' ] - security_group_id: - description: - - Security Group id used to scale ECS instances. - group_id: - description: - - ID of the scaling group of a scaling configuration. - aliases: [ 'scaling_group_id' ] - internet_charge_type: - description: - - Internet charge type of scaling ECS instance. - default: "PayByBandwidth" - choices: ["PayByBandwidth", "PayByTraffic"] - max_bandwidth_in: - description: - - For scaling ECS instance, maximum incoming bandwidth from the public network, measured in Mbps (Mega bit per second). - Valid values range [1,200]. - default: 200 - max_bandwidth_out: - description: - - For scaling ECS instance, maximum outgoing bandwidth to the public network, measured in Mbps (Mega bit per second). - Valid values range [0,100]. - default: 0 - system_disk_category: - description: - - Category of the system disk. - default: "cloud_efficiency" - choices: ["cloud_efficiency", "cloud_ssd"] - system_disk_size: - description: - - Size of the system disk, in GB. The valid value range [40, 500]. Default to maximum of specified value and image size. - id: - description: - - The ID of existing scaling configuration. - aliases: [ 'configuration_id' ] - data_disks: - description: - - List of hash/dictionaries data disks for scaling ECS instances. A maximum of four items can be entered. - suboptions: - size: - description: - - Size of data disk, in GB. The valid value range [20, 32768]. Ignored when I(snapshot_id). - category: - description: - - Category of data disk. - default: "cloud_efficiency" - choices: ["cloud_efficiency", "cloud_ssd"] - snapshot_id: - description: - - Snapshot used for creating the data disk. - delete_with_instance: - description: - - Whether the data disk will be released along with the instance. - type: bool - default: True - tags: - description: - - A hash/dictionaries of instance tags, to add to the new instance or for starting/stopping instance by tag. C({"key":"value"}) - key_name: - description: - - The name of key pair which is used to access ECS instance in SSH. - aliases: ['keypair'] - user_data: - description: - - User-defined data to customize the startup behaviors of an ECS instance and to pass data into an ECS instance. - It only will take effect when launching the new ECS instances. - ram_role_name: - description: - - The name of the instance RAM role. - aliases: ['ram_role'] - -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.3.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# basic provisioning example scaling configuration -- name: basic provisioning example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - image: ubuntu1404_64_40G_cloudinit_20160727.raw - instance_type: ecs.n4.small - max_bandwidth_out: 10 - system_disk_category: cloud_efficiency - system_disk_size: 100 - internet_charge_type: PayByBandwidth - security_group_id: sg-f2rwnfh23r - group_id: asg-2zebnrbt206pex - key_name: key-pair-for-ess - name: configuration-from-ansible - data_disks: - - size: 50 - category: cloud_efficiency - - snapshot_id: s-w3cif22r2rd - category: cloud_efficiency - tags: - CreatedBy: 'Ansible' - Version: '1' - - tasks: - - name: launch scaling configuration - alicloud_ess_configuration: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - image: '{{ image }}' - system_disk_category: '{{ system_disk_category }}' - system_disk_size: '{{ system_disk_size }}' - instance_type: '{{ instance_type }}' - internet_charge_type: '{{ internet_charge_type }}' - max_bandwidth_out: '{{ max_bandwidth_out }}' - key_name: '{{ key_name }}' - - - name: launch scaling configuration with data disks and tags - alicloud_ess_configuration: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - image: '{{ image }}' - system_disk_category: '{{ system_disk_category }}' - system_disk_size: '{{ system_disk_size }}' - instance_type: '{{ instance_type }}' - internet_charge_type: '{{ internet_charge_type }}' - max_bandwidth_out: '{{ max_bandwidth_out }}' - key_name: '{{ key_name }}' - data_disks: '{{ data_disks }}' - tags: '{{ tags }}' - - - name: delete specified scaling configuration - alicloud_ess_configuration: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - name: '{{ image }}' - state: absent - -''' - -RETURN = ''' -id: - description: Scaling Configuration ID. - returned: expect absent - type: str - sample: "asc-2zeimuvzeil1ybfd2lt3" -name: - description: Scaling Configuration name. - returned: expect absent - type: str - sample: ess-configuration-foo -group_id: - description: ID of the scaling group of a scaling configuration. - returned: expect absent - type: str - sample: "asg-2zeimuvzeil1xfuor9ej" -configuration: - description: The details of a scaling configuration. - returned: expect absent - type: dict - sample: { - "creation_time": "2018-01-05T14:03Z", - "group_id": "asg-2zeimuvzeil1xfuor9ej", - "id": "asc-2zeimuvzeil1ybfd2lt3", - "image_id": "centos_6_09_64_20G_alibase_20170825.vhd", - "instance_type": "ecs.n4.small", - "name": "test-for-ansible", - "security_group_id": "sg-2zeb86qfocdo7pvk41tt", - "status": "inactive" - } -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_details(configuration): - return dict(id=configuration.id, - name=configuration.name, - group_id=configuration.scaling_group_id, - status=configuration.status, - image_id=configuration.image_id, - instance_type=configuration.instance_type, - security_group_id=configuration.security_group_id, - data_disks=getattr(configuration,'data_disks', None), - creation_time=configuration.creation_time) - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - group_id=dict(type='str', aliases=['scaling_group_id']), - instance_type=dict(type='str', aliases=['type']), - image_id=dict(type='str', aliases=['image']), - name=dict(type='str', aliases=['configuration_name']), - internet_charge_type=dict(type='str', default="PayByBandwidth", choices=["PayByBandwidth", "PayByTraffic"]), - max_bandwidth_in=dict(type='int', default=200), - max_bandwidth_out=dict(type='int', default=0), - system_disk_category=dict(type='str', default='cloud_efficiency'), - system_disk_size=dict(type='int', default='40'), - tags=dict(type='dict'), - state=dict(default='present', choices=['present', 'absent']), - id=dict(type='str', aliases=['configuration_id']), - key_name=dict(type='str', aliases=['keypair']), - user_data=dict(type='str'), - data_disks=dict(type='list'), - security_group_id=dict(type='str'), - ram_role_name=dict(type='str', aliases=['ram_role']) - )) - - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for the module alicloud_ess_configuration.") - - ess = ess_connect(module) - state = module.params['state'] - cfg_id = module.params['id'] - cfg_name = module.params['name'] - scaling_group = module.params['group_id'] - changed = False - - current = None - all_cfgs = [] - if cfg_id or cfg_name: - cfgs = ess.describe_configurations(scaling_group_id=scaling_group, scaling_configuration_ids=[cfg_id], - scaling_configuration_names=[cfg_name]) - - if cfgs: - if len(cfgs) > 1: - for cfg in cfgs: - all_cfgs.append(cfg.id) - module.fail_json(msg="There are several scaling configurations in our record based on name {0}: {1}. " - "Please specified one using 'id' and try again.".format(cfg_name, all_cfgs)) - current = cfgs[0] - - if state == 'present': - if current is None: - try: - data_disks = module.params['data_disks'] - if not isinstance(data_disks, list): - module.fail_json(msg="Filed 'data_disks' should be a list, aborting.") - - if not isinstance(module.params['tags'], dict): - module.fail_json(msg="Filed 'tags' should be a dict, aborting.") - - current = ess.create_configuration(scaling_group_id=scaling_group, - image_id=module.params['image_id'], - instance_type=module.params['instance_type'], - security_group_id=module.params['security_group_id'], - name=cfg_name, - internet_charge_type=module.params['internet_charge_type'], - max_bandwidth_in=module.params['max_bandwidth_in'], - max_bandwidth_out=module.params['max_bandwidth_out'], - system_disk_category=module.params['system_disk_category'], - system_disk_size=module.params['system_disk_size'], - data_disks=data_disks, - tags=module.params['tags'], - key_pair_name=module.params['key_name'], - ram_role_name=module.params['ram_role_name'], - user_data=module.params['user_data']) - changed = True - except Exception as e: - module.fail_json(msg="Create scaling configuration got an error: {0}".format(e)) - - module.exit_json(changed=changed, id=current.id, name=current.name, group_id=current.group_id, configuration=get_details(current)) - - if current is None: - if cfg_id or cfg_name: - module.fail_json(msg="There are no scaling configuration in our record based on id {0} or name {1}. " - "Please check it and try again.".format(cfg_id, cfg_name)) - module.fail_json(msg='Please specify a scaling configuration that you want to terminate by parameters id or name, aborting') - - try: - module.exit_json(changed=current.terminate()) - except Exception as e: - module.fail_json(msg='Delete scaling configuration {0} got an error: {1}'.format(current.id, e)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_ess_group.py b/lib/ansible/modules/cloud/alicloud/_alicloud_ess_group.py deleted file mode 100644 index b24fdf85..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_ess_group.py +++ /dev/null @@ -1,328 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_ess_group -version_added: "1.0.9" -short_description: Create or Terminate an scaling group in ESS. -description: - - A scaling group is a collection of ECS instances with similar configuration deployed in an application scenario. - It defines the maximum and minimum number of ECS instances in the group, - associated Server Load Balancer and RDS instances, and other attributes. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_ess_group) instead. -options: - state: - description: - - The state of the scaling group after operating. - default: 'present' - choices: [ 'present', 'active', 'inactive', 'absent' ] - name: - description: - - Name shown for the scaling group, which must contain 2-40 characters (English or Chinese). - The name must begin with a number, an upper/lower-case letter or a Chinese character and may contain numbers, "_", "-" or ".". - Default to scaling group ID. - aliases: ['group_name' ] - max_size: - description: - - Maximum number of ECS instances in the scaling group. Value range [0, 100]. - min_size: - description: - - Minimum number of ECS instances in the scaling group. Value range [0, 100]. Required when C(state=present). - cooldown: - description: - - Default cool-down time (in seconds) of the scaling group. Value range [0, 86400]. - default: 300 - aliases: [ 'default_cooldown' ] - removal_policies: - description: - - Policy for removing ECS instances from the scaling group. Optional values - OldestInstance(removes the first ECS instance attached to the scaling group); - NewestInstance(removes the first ECS instance attached to the scaling group); - OldestScalingConfiguration(removes the ECS instance with the oldest scaling configuration). - default: ["OldestScalingConfiguration","OldestInstance"] - choices: ["OldestScalingConfiguration","NewestInstance","OldestInstance"] - load_balancer_ids: - description: - - ID list of a Server Load Balancer instance. At most 5 Load Balancer instance supported. - aliases: [ 'lb_ids' ] - db_instance_ids: - description: - - ID list of an RDS instance. At most 8 RDS instance supported. - aliases: [ 'db_ids' ] - vswitch_ids: - description: - - ID list of a VSwitch. At most 8 vswitch supported. - The priority of VSwitches descends from 1 to 5, and 1 indicates the highest priority. - aliases: [ 'subnet_ids' ] - id: - description: - - The ID of existing scaling group. - aliases: [ 'group_id' ] - configuration_id: - description: - - ID of the active scaling configuration in the scaling group. Required when C(state=active). - aliases: [ 'scaling_configuration_id' ] - -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.3.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# basic provisioning example scaling group -- name: basic provisioning example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - ess_group_name: foo - max_size: 2 - min_size: 0 - cooldown: 400 - removal_policies: - - 'OldestScalingConfiguration' - - 'OldestInstance' - group_id: asg-fh323iwefncew31 - configuration_id: asc-2ze4zleeettwd4sfnrkk - - tasks: - - name: Create scaling group - alicloud_ess_group: - alicloud_region: '{{ alicloud_region }}' - max_size: '{{ max_size }}' - min_size: '{{ min_size }}' - name: '{{ ess_group_name }}' - vswitch_ids: - - '{{ subnet.vswitch_id }}' - - - name: active a specified scaling group - alicloud_ess_group: - alicloud_region: '{{ alicloud_region }}' - configuration_id: '{{ configuration.id }}' - id: '{{ group_id }}' - state: active - -''' - -RETURN = ''' -id: - description: The ID of existing scaling group. - returned: expect absent - type: str - sample: "asg-2zefe4bi0jpc3tqi8mn8" -name: - description: The ID of existing scaling group. - returned: expect absent - type: str - sample: "foo" -configuration_id: - description: ID of the active scaling configuration in the scaling group. - returned: expect absent - type: str - sample: "asc-2ze4zleeettwd4sfnrkk" -group: - description: The details of a scaling group. - returned: expect absent - type: dict - sample: { - "configuration_id": asc-2ze4zleeettwd4sfnrkk, - "cooldown": 300, - "creation_time": "2018-01-08T05:42Z", - "db_ids": null, - "id": "asg-2zefe4bi0jpc3tqi8mn8", - "load_balancer_id": null, - "max_size": 2, - "min_size": 0, - "name": "foo", - "status": "active", - "vswitch_ids": [ - "vsw-2zevfsoh2v7en50w9up6u" - ], - "id": "asg-2zefe4bi0jpc3tqi8mn8", - "name": "foo" - } -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_details(group): - result = dict(id=group.id, - name=group.name, - configuration_id=group.configuration_id, - status=group.status, - max_size=group.max_size, - min_size=group.min_size, - load_balancer_id=getattr(group, 'load_balancer_id', None), - cooldown=group.cooldown, - db_ids=getattr(group, 'db_instance_ids', None), - creation_time=group.creation_time - ) - vswitch_ids = getattr(group, 'vswitch_ids', None) - if vswitch_ids: - result['vswitch_ids'] = vswitch_ids['vswitch_id'] - - return result - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - name=dict(type=str, aliases=['group_name']), - max_size=dict(type=int), - min_size=dict(type=int), - state=dict(type=str, default='present', choices=['present', 'active', 'inactive', 'absent']), - id=dict(type=str, aliases=['group_id']), - cooldown=dict(type=int, default=300, aliases=['default_cooldown']), - removal_policies=dict(type=list, default=['OldestScalingConfiguration','OldestInstance']), - load_balancer_ids=dict(type=list, aliases=['lb_ids']), - db_instance_ids=dict(type=list, aliases=['db_ids']), - vswitch_ids=dict(type=list, aliases=['subnet_ids']), - configuration_id=dict(type=str, aliases=['scaling_configuration_id']) - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for the module alicloud_ess_group.") - - ess = ess_connect(module) - state = module.params['state'] - group_id = module.params['id'] - group_name = module.params['name'] - max_size = module.params['max_size'] - min_size = module.params['min_size'] - cooldown = module.params['cooldown'] - removal_policies = module.params['removal_policies'] - configuration_id = module.params['configuration_id'] - - changed = False - - current = None - all_groups = [] - if group_id or group_name: - groups = ess.describe_groups(scaling_group_ids=[group_id], scaling_group_names=[group_name]) - - if groups: - for group in groups: - all_groups.append(group.id) - - if len(all_groups) > 1: - module.fail_json(msg="There are several scaling group in our record based on name {0}: {1}. " - "Please specified one using 'id' and try again.".format(group_name, all_groups)) - - current = groups[0] - - if state == 'present': - if current is None: - try: - if max_size is None or max_size < 0 or max_size > 100: - module.fail_json(msg="'max_size': required field when state is 'present' and its value range [0, 100]. " - "Please check it and try again.") - if min_size is None or min_size < 0 or min_size > 100: - module.fail_json(msg="'min_size': required field when state is 'present' and its value range [0, 100]. " - "Please check it and try again.") - lb_ids = module.params['load_balancer_ids'] - db_ids = module.params['db_instance_ids'] - vsw_ids = module.params['vswitch_ids'] - if lb_ids and not isinstance(lb_ids, list): - module.fail_json(msg="Filed 'load_balancer_ids' should be a list, aborting.") - if db_ids and not isinstance(db_ids, list): - module.fail_json(msg="Filed 'db_instance_ids' should be a list, aborting.") - if vsw_ids and not isinstance(vsw_ids, list): - module.fail_json(msg="Filed 'vswitch_ids' should be a list, aborting.") - - current = ess.create_group(max_size=max_size, min_size=min_size, name=group_name, - default_cooldown=cooldown, removal_policies=removal_policies, - load_balancer_ids=lb_ids, db_instance_ids=db_ids, vswitch_ids=vsw_ids) - changed = True - except Exception as e: - module.fail_json(msg="Create scaling group got an error: {0}".format(e)) - - # Modify scaling group attribute - if group_name != current.name or max_size != current.max_size or min_size != current.min_size \ - or configuration_id != current.configuration_id or cooldown != current.cooldown \ - or removal_policies != current.removal_policies['removal_policy']: - changed = current.modify(max_size=max_size, min_size=min_size, name=group_name, default_cooldown=cooldown, - removal_policies=removal_policies, scaling_configuration_id=configuration_id) - - module.exit_json(changed=changed, id=current.id, name=current.name, configuration_id=current.configuration_id, - group=get_details(current)) - - if current is None: - if group_id or group_name: - module.fail_json(msg="There are no scaling group in our record based on id {0} or name {1}. " - "Please check it and try again.".format(group_id, group_name)) - module.fail_json(msg='Please specify a scaling group that you want to operate by parameters id or name, aborting') - - if state == 'absent': - try: - module.exit_json(changed=current.terminate()) - except Exception as e: - module.fail_json(msg='Delete scaling group {0} got an error: {1}'.format(current.id, e)) - - if state == 'active': - try: - if str.lower(current.status) == 'inactive' or current.configuration_id != configuration_id: - changed = current.enable(scaling_configuration_id=configuration_id) - current = ess.describe_groups(scaling_group_ids=[group_id])[0] - - except Exception as e: - module.fail_json(msg='Active scaling group {0} got an error: {1}.'.format(current.id, e)) - - elif state == 'inactive': - try: - if str.lower(current.status) == 'active': - changed = current.disable() - current = ess.describe_groups(scaling_group_ids=[group_id])[0] - - except Exception as e: - module.fail_json(msg='Inactive scaling group {0} got an error: {1}.'.format(current.id, e)) - - module.exit_json(changed=changed, id=current.id, name=current.name, configuration_id=current.configuration_id, - group=get_details(current)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_ess_instance.py b/lib/ansible/modules/cloud/alicloud/_alicloud_ess_instance.py deleted file mode 100644 index 6fadb514..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_ess_instance.py +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_ess_instance -version_added: "1.0.9" -short_description: Add or Remove several ECS instances in ESS -description: - - Add several ECS instances to a specified scaling group; - Remove several ECS instances from a specified scaling group. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_ess_instance) instead. -options: - state: - description: - - present to add ECS instances; - absent to remove ECS instances. - default: 'present' - choices: [ 'present', 'absent' ] - group_id: - description: - - The ID of a scaling group. - required: True - instance_ids: - description: - - ID list of an ECS instance. At most 20 ECS instance supported. Required when C(state='present'). - creation_type: - description: - - ECS instance creation type. Valid when C(state='absent', instance_ids=None). - 'AutoCreated' for the ECS instance is automatically created by the Auto Scaling service in the scaling group. - 'Attached' for the ECS instance is created outside the Auto Scaling service and manually attached to the scaling group. - choices: [ 'AutoCreated', 'Attached' ] - default: 'Attached' - aliases: [ 'type' ] - -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.3.0" -notes: - - If both I(instance_ids) and I(creation_type) are not specified, the module will remove all of ECS instnaces in the - specified Scaling Group when C(state=absent). -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# basic provisioning example scaling instance -- name: basic provisioning example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - instance_ids: - - "i-2ze2y4x26l66h4b4u884" - - "i-2ze0eyu760pkh468uwg7" - group_id: asg-2zebnrbt206pex - - tasks: - - name: add instances to specified - alicloud_ess_instance: - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance_ids }}' - group_id: '{{ group_id }}' - - - name: remove auto-created instances - alicloud_ess_instance: - alicloud_region: '{{ alicloud_region }}' - creation_type: 'AutoCreated' - group_id: '{{ group_id }}' - state: absent - - - name: remove all of ECS instances - alicloud_ess_instance: - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ group_id }}' - state: absent -''' - -RETURN = ''' -changed: - description: The result of adding or removing. - returned: when success - type: bool - sample: true -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - state=dict(type=str, default='present', choices=['present', 'absent']), - group_id=dict(type=str, required=True), - instance_ids=dict(type=list), - creation_type=dict(type=str, default='Attached', choices=['AutoCreated', 'Attached'], aliases=['type']) - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for the module alicloud_ess_instance.") - - ess = ess_connect(module) - state = module.params['state'] - group_id = module.params['group_id'] - instance_ids = module.params['instance_ids'] - creation_type = module.params['creation_type'] - - if state == 'present' and not instance_ids: - module.fail_json(msg="Field 'instance_ids' is required when state is 'present'. Aborting.") - - changed = False - adding = instance_ids - removing = [] - all = [] - old = ess.describe_instances(scaling_group_id=group_id) - if old: - for inst in old: - if instance_ids: - if inst.id in instance_ids: - adding.remove(inst.id) - removing.append(inst.id) - if state == 'absent' and creation_type and inst.creation_type == creation_type: - removing.append(inst.id) - all.append(inst.id) - - if state == 'present': - if adding: - try: - changed = ess.attach_instances(scaling_group_id=group_id, instance_ids=adding) - module.exit_json(changed=changed) - except Exception as e: - module.fail_json(msg="Adding ECS instances to scaling group got an error: {0}.".format(e)) - - if not removing: - removing = all - - if removing: - try: - changed = ess.remove_instances(scaling_group_id=group_id, instance_ids=removing) - except Exception as e: - module.fail_json(msg='Removing ECS instances from scaling group got an error: {0}.'.format(e)) - - module.exit_json(changed=changed) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_ess_rule.py b/lib/ansible/modules/cloud/alicloud/_alicloud_ess_rule.py deleted file mode 100644 index d7476f4c..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_ess_rule.py +++ /dev/null @@ -1,260 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_ess_rule -version_added: "1.0.9" -short_description: Create or Terminate an scaling rule in ESS. -description: - - A scaling rule defines specific scaling actions, for example, adding or removing n ECS instances. - If the execution of a scaling rule results in a number of ECS instances in the scaling group that is less than - the MinSize or greater than the MaxSize, Auto Scaling automatically adjusts the number of ECS instances to be - added or removed by executing the "Adjust scaling group instance quantity to MinSize" - or "Adjust scaling group instance quantity to MaxSize" rule. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_ess_rule) instead. -options: - state: - description: - - present to create a scaling rule and absent to delete it. - default: 'present' - choices: [ 'present', 'absent' ] - name: - description: - - The name of scaling rule. - - It must contain 2-40 English or Chinese characters, and start with a number, a letter in upper or - lower case or a Chinese character, and it can contain numbers, "_", "-" or ".". - - Default to scaling rule Id. - aliases: ['rule_name'] - adjustment_type: - description: - - Adjustment mode of a scaling rule. - - QuantityChangeInCapacity used to increase or decrease a specified number of ECS instances; - - PercentChangeInCapacity used to increase or decrease a specified proportion of ECS instances; - - TotalCapacity used to adjust the quantity of ECS instances in the current scaling group to a specified value. - - Required when C(state=present). - aliases: [ 'type' ] - choices: ['QuantityChangeInCapacity', 'PercentChangeInCapacity', 'TotalCapacity'] - adjustment_value: - description: - - Adjusted value of a scaling rule. - - QuantityChangeInCapacity to (0, 100] U (-100, 0]; - - PercentChangeInCapacity to [0, 10000] U [-10000, 0]; - - TotalCapacity to [0, 100]. - - Required when C(state=present). - aliases: [ 'value' ] - cooldown: - description: - - Cool-down time of a scaling rule. Value range to [0, 86400], in seconds. The default value is empty. - group_id: - description: - - ID of the scaling group of a scaling rule. Required when C(state=present). - aliases: [ 'scaling_group_id' ] - id: - description: - - The ID of existing scaling rule. - aliases: [ 'rule_id' ] - -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.3.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -- name: basic example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - cooldown: 400 - group_id: asg-2zeimuvzeil1xfuor9ej - name: ess-rule-foo - adjustment_type: QuantityChangeInCapacity - adjustment_value: 3 - - tasks: - - name: launch scaling rule - alicloud_ess_rule: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ essgroup.id }}' - adjustment_type: '{{adjustment_type}}' - adjustment_value: '{{adjustment_value}}' - cooldown: '{{cooldown}}' - name: '{{name}}' - - - name: delete specified scaling rule - alicloud_ess_rule: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - name: '{{ name }}' - state: absent - -''' - -RETURN = ''' -id: - description: Scaling Rule ID. - returned: expect absent - type: str - sample: "asr-2zefe4bi0jpctd6z726p" -name: - description: Scaling Rule name. - returned: expect absent - type: str - sample: ess-rule-foo -group_id: - description: ID of the scaling group of a scaling rule. - returned: expect absent - type: str - sample: "asg-2zeimuvzeil1xfuor9ej" -rule: - description: The details of a scaling rule. - returned: expect absent - type: dict - sample: { - "adjustment_type": "QuantityChangeInCapacity", - "adjustment_value": 3, - "ari": "ari:acs:ess:cn-beijing:1204663572767468:scalingrule/asr-2zefe4bi0jpctd6z726p", - "cooldown": 400, - "group_id": "asg-2zegiwc8m3ccxj0y1rbq", - "id": "asr-2zefe4bi0jpctd6z726p", - "name": "from-ansible-roles-test_ess" - } -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_details(rule): - return dict(id=rule.id, - name=rule.name, - group_id=rule.scaling_group_id, - ari=rule.ari, - cooldown=rule.cooldown, - adjustment_type=rule.adjustment_type, - adjustment_value=rule.adjustment_value - ) - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - group_id=dict(type='str', aliases=['scaling_group_id']), - adjustment_type=dict(type='str', aliases=['type'], choices=['QuantityChangeInCapacity', 'PercentChangeInCapacity', 'TotalCapacity']), - adjustment_value=dict(type='int', aliases=['value']), - name=dict(type='str', aliases=['rule_name']), - cooldown=dict(type='int'), - state=dict(type='str', default='present', choices=['present', 'absent']), - id=dict(type='str', aliases=['rule_id']) - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for the module alicloud_ess_rule.") - - ess = ess_connect(module) - state = module.params['state'] - rule_id = module.params['id'] - rule_name = module.params['name'] - scaling_group = module.params['group_id'] - adjustment_type = module.params['adjustment_type'] - adjustment_value = module.params['adjustment_value'] - cooldown = module.params['cooldown'] - changed = False - - current = None - all_rules = [] - if rule_id or rule_name: - rules = ess.describe_rules(scaling_group_id=scaling_group, scaling_rule_ids=[rule_id], scaling_rule_names=[rule_name]) - - if rules: - if len(rules) > 1: - for r in rules: - all_rules.append(r.id) - module.fail_json(msg="There are several scaling rules in our record based on name {0}: {1}. " - "Please specified one using 'id' and try again.".format(rule_name, all_rules)) - current = rules[0] - - if state == 'present': - if current is None: - try: - if not scaling_group: - module.exit_json(msg="'group_id': required field when state is present, aborting.") - if not adjustment_type: - module.exit_json(msg="'adjustment_type': required field when state is present, aborting.") - if not adjustment_value: - module.exit_json(msg="'adjustment_value': required field when state is present, aborting.") - current = ess.create_rule(scaling_group_id=scaling_group, adjustment_type=adjustment_type, - adjustment_value=adjustment_value, name=rule_name, cooldown=cooldown) - changed = True - except Exception as e: - module.fail_json(msg="Create scaling rule got an error: {0}".format(e)) - - else: - try: - changed = current.modify(adjustment_type=adjustment_type, adjustment_value=adjustment_value, - name=rule_name, cooldown=cooldown) - if changed: - current = current.update(validate=True) - except Exception as e: - module.fail_json(msg="Modify scaling rule got an error: {0}".format(e)) - module.exit_json(changed=changed, id=current.id, name=current.name, group_id=current.group_id, rule=get_details(current)) - - if current is None: - if rule_id or rule_name: - module.fail_json(msg="There are no scaling rule in our record based on id {0} or name {1}. " - "Please check it and try again.".format(rule_id, rule_name)) - module.fail_json(msg='Please specify a scaling rule that you want to terminate by parameters id or name, aborting') - - try: - module.exit_json(changed=current.terminate()) - except Exception as e: - module.fail_json(msg='Delete scaling rule {0} got an error: {1}'.format(current.id, e)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_ess_task.py b/lib/ansible/modules/cloud/alicloud/_alicloud_ess_task.py deleted file mode 100644 index f64b6c57..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_ess_task.py +++ /dev/null @@ -1,326 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_ess_task -version_added: "1.0.9" -short_description: Create or Terminate an scheduled task in ESS. -description: - - A scheduled task used to execute scaling activity in a scaling group automatically. - - At most 20 scheduled tasks can be specified in a account. - - When the trigger of a scheduled task fails because a scaling activity in a scaling group is in progress or - the scaling group is disabled, the scheduled task is automatically retried within the LaunchExpirationTime; - otherwise, the scheduled trigger task is abandoned. - - If multiple tasks are scheduled at similar times to execute the rule of the same group, - the earliest task triggers the scaling activity first, and other tasks make attempts to execute the rule - within their Launch Expiration Time because a scaling group executes only one scaling activity at a time. - If another scheduled task is still making triggering attempts within its Launch Expiration Time after the - scaling activity is finished, the scaling rule is executed and the corresponding scaling activity is triggered. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_ess_task) instead. -options: - state: - description: - - present to create a scheduled task and absent to delete it. - default: 'present' - choices: [ 'present', 'absent' ] - rule_id: - description: - - ID of the scaling rule of a scheduled task. Required when C(state=present) - launch_time: - description: - - Time point at which the scheduled task is triggered. - - The date format follows the ISO8601 standard and uses UTC time. It is in the format of YYYY-MM-DDThh:mmZ. - - If I(recurrence_type), the time point specified by this attribute is the default time point at which the circle is executed. - Otherwise, the task is executed once on the designated date and time. - - A time point 90 days after creation or modification cannot be inputted. - - Required when C(state=present). - launch_expiration: - description: - - Time period within which the failed scheduled task is retried, in second. Value range [0, 21600]. - default: 600 - aliases: ['expiration'] - name: - description: - - Display name of the scheduled task. - - It must be 2-40 characters (English or Chinese) long, and begin with a number, an upper/lower-case letter - or a Chinese character and may contain numbers, "_", "-" or ".". - - Default to scheduled task ID. - aliases: ['task_name' ] - description: - description: - - Description of the scheduled task, which is 2-200 characters (English or Chinese) long. - recurrence_type: - description: - - Type of the scheduled task to be repeated. Optional values 'Daily', 'Weekly' and 'Monthly' - to indicates recurrence interval by day, week or month for a scheduled task. - - I(recurrence_type, recurrence_value, recurrence_endtime) must be specified or not at the same time. - aliases: [ 'type' ] - choices: ['Daily', 'Weekly', 'Monthly'] - recurrence_value: - description: - - Value of the scheduled task to be repeated. - - Daily should only supported one value in the range [1,31]. - - Weekly support multiple values. The values of Sunday to Saturday are 0 to 6 in sequence. - Multiple values shall be separated by a comma ",". - - Monthly use format A-B and the value range of A and B is 1 to 31, and the B value must be greater than the A value. - - I(recurrence_type, recurrence_value, recurrence_endtime) must be specified or not at the same time. - aliases: [ 'value' ] - recurrence_endtime: - description: - - End time of the scheduled task to be repeated. - The date format follows the ISO8601 standard and uses UTC time. It is in the format of YYYY-MM-DDThh:mmZ. - A time point 90 days after creation or modification cannot be inputted. - - I(recurrence_type, recurrence_value, recurrence_endtime) must be specified or not at the same time. - aliases: [ 'endtime' ] - enabled: - description: - - Whether to enable the scheduled task. - default: True - type: bool - id: - description: - - The ID of existing scheduled task. - aliases: [ 'task_id' ] - -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.3.0" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -- name: basic provisioning example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - rule_id: asr-2zefe4bi0jpctd6z726p - launch_time: 2018-01-09T15:00Z - launch_expiration: 300 - recurrence_type: 'Daily' - recurrence_value: 10 - recurrence_endtime: 2018-02-10T15:00Z - name: task-from-ansible - - tasks: - - name: launch scheduled task - alicloud_ess_task: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - name: '{{ name }}' - rule_id: '{{ rule.id }}' - launch_time: '{{ launch_time }}' - launch_expiration: '{{ launch_expiration }}' - recurrence_type: '{{ recurrence_type }}' - recurrence_value: '{{ recurrence_value }}' - recurrence_endtime: '{{ recurrence_endtime }}' - - - name: delete specified scheduled task - alicloud_ess_task: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - name: '{{ name }}' - state: absent - -''' - -RETURN = ''' -id: - description: Scheduled Task ID. - returned: expect absent - type: str - sample: "cItPa1ec7ii6dryMmEbBnJZP" -name: - description: Scheduled Task name. - returned: expect absent - type: str - sample: ess-task-foo -task: - description: The details of a scheduled task. - returned: expect absent - type: dict - sample: { - "description": null, - "enabled": true, - "id": "cItPa1ec7ii6dryMmEbBnJZP", - "launch_expiration": 300, - "launch_time": "2018-01-09T15:00Z", - "name": "ess-task-foo", - "recurrence_endtime": "2018-02-10T15:00Z", - "recurrence_type": "Daily", - "recurrence_value": "10", - "rule_ari": "ari:acs:ess:cn-beijing:1204663572767468:scalingrule/asr-2zefe4bi0jpctd6z726p" - } -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_details(task): - return dict(id=task.id, - name=task.name, - rule_ari=task.rule_ari, - description=getattr(task, 'description', None), - launch_time=task.launch_time, - launch_expiration=task.launch_expiration, - recurrence_type=task.recurrence_type, - recurrence_value=task.recurrence_value, - recurrence_endtime=task.recurrence_end_time, - enabled=task.enabled, - ) - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - rule_id=dict(type='str'), - launch_time=dict(type='str'), - launch_expiration=dict(type='int', defalut=600, aliases=['expiration']), - name=dict(type='str', aliases=['task_name']), - description=dict(type='str'), - recurrence_type=dict(type='str', choices=['Daily', 'Weekly', 'Monthly'], aliases=['type']), - recurrence_value=dict(type='str', aliases=['value']), - recurrence_endtime=dict(type='str', aliases=['endtime']), - state=dict(type='str', default='present', choices=['present', 'absent']), - enabled=dict(type='bool', default=True), - id=dict(type='str', aliases=['task_id']) - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for the module alicloud_ess_task.") - - ess = ess_connect(module) - state = module.params['state'] - task_id = module.params['id'] - task_name = module.params['name'] - rule_id = module.params['rule_id'] - launch_time = module.params['launch_time'] - launch_expiration = module.params['launch_expiration'] - recurrence_type = module.params['recurrence_type'] - recurrence_value = module.params['recurrence_value'] - recurrence_endtime = module.params['recurrence_endtime'] - enabled = module.params['enabled'] - description = module.params['description'] - - # Get scaling rule ari according rule ID - rule_ari = None - if rule_id: - rules = ess.describe_rules(scaling_rule_ids=[rule_id]) - rule_ari = rules[0].ari - - count = 0 - if recurrence_type: - count += 1 - if recurrence_value: - count += 1 - if recurrence_endtime: - count += 1 - if count in (1, 2): - module.fail_json(msg="'recurrence_type', 'recurrence_value' and 'recurrence_endtime' must be specified or not at the same time") - - changed = False - - current = None - all_tasks = [] - if task_id or task_name: - tasks = ess.describe_scheduled_tasks(scheduled_task_ids=[task_id], scheduled_task_names=[task_name], - scaling_rule_aris=[rule_ari]) - - if tasks: - if len(tasks) > 1: - for task in tasks: - all_tasks.append(task.id) - module.fail_json(msg="There are several scheduled tasks in our record based on name {0}: {1}. " - "Please specified one using 'id' and try again.".format(task_name, all_tasks)) - current = tasks[0] - - if state == 'present': - if current is None: - try: - if not rule_id: - module.exit_json(msg="'rule_id': required field when state is present, aborting.") - if not rule_ari: - module.exit_json(msg="There is no scheduled task in our record based on rule id {0}, aborting." - "Please check it and try again.".format(rule_id)) - if not launch_time: - module.exit_json(msg="'launch_time': required field when state is present, aborting.") - - current = ess.create_scheduled_task(scaling_rule_ari=rule_ari, launch_time=launch_time, name=task_name, - description=description, launch_expiration_time=launch_expiration, - recurrence_type=recurrence_type, recurrence_value=recurrence_value, - recurrence_end_time=recurrence_endtime, task_enabled=enabled) - changed = True - except Exception as e: - module.fail_json(msg="Create scheduled task got an error: {0}".format(e)) - - else: - try: - changed = current.modify(scaling_rule_ari=rule_ari, launch_time=launch_time, name=task_name, - description=description, launch_expiration_time=launch_expiration, - recurrence_type=recurrence_type, recurrence_value=recurrence_value, - recurrence_end_time=recurrence_endtime, task_enabled=enabled) - if changed: - current = current.update(validate=True) - except Exception as e: - module.fail_json(msg="Modify scheduled rule got an error: {0}".format(e)) - - module.exit_json(changed=changed, id=current.id, name=current.name, task=get_details(current)) - - if current is None: - if task_id or task_name: - module.fail_json(msg="There are no scheduled task in our record based on id {0} or name {1}. " - "Please check it and try again.".format(task_id, task_name)) - module.fail_json(msg='Please specify a scheduled task that you want to terminate by field id or name, aborting') - - try: - module.exit_json(changed=current.terminate()) - except Exception as e: - module.fail_json(msg='Delete scheduled task {0} got an error: {1}'.format(current.id, e)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_instance.py b/lib/ansible/modules/cloud/alicloud/_alicloud_instance.py deleted file mode 100644 index a0279fab..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_instance.py +++ /dev/null @@ -1,589 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_instance -version_added: "1.0.9" -short_description: Create, Start, Stop, Restart or Terminate an Instance in ECS. Add or Remove Instance to/from a Security Group. -description: - - Create, start, stop, restart, modify or terminate ecs instances. - - Add or remove ecs instances to/from security group. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_instance) instead. -options: - state: - description: - - The state of the instance after operating. - default: 'present' - choices: [ 'present', 'running', 'stopped', 'restarted', 'absent' ] - alicloud_zone: - description: - - Aliyun availability zone ID in which to launch the instance. - If it is not specified, it will be allocated by system automatically. - aliases: ['zone_id', 'zone' ] - image_id: - description: - - Image ID used to launch instances. Required when C(state=present) and creating new ECS instances. - aliases: [ 'image' ] - instance_type: - description: - - Instance type used to launch instances. Required when C(state=present) and creating new ECS instances. - aliases: [ 'type' ] - group_id: - description: - - Security Group id used to launch instance or join/remove existing instances to/from the specified Security Group. - aliases: [ 'security_group_id' ] - vswitch_id: - description: - - The subnet ID in which to launch the instances (VPC). - aliases: ['subnet_id'] - instance_name: - description: - - The name of ECS instance, which is a string of 2 to 128 Chinese or English characters. It must begin with an - uppercase/lowercase letter or a Chinese character and can contain numerals, ".", "_" or "-". - It cannot begin with http:// or https://. - aliases: ['name'] - description: - description: - - The description of ECS instance, which is a string of 2 to 256 characters. It cannot begin with http:// or https://. - internet_charge_type: - description: - - Internet charge type of ECS instance. - default: "PayByBandwidth" - choices: ["PayByBandwidth", "PayByTraffic"] - max_bandwidth_in: - description: - - Maximum incoming bandwidth from the public network, measured in Mbps (Mega bit per second). - default: 200 - max_bandwidth_out: - description: - - Maximum outgoing bandwidth to the public network, measured in Mbps (Mega bit per second). - default: 0 - host_name: - description: - - Instance host name. - password: - description: - - The password to login instance. After rebooting instances, the modified password would be take effect. - system_disk_category: - description: - - Category of the system disk. - default: "cloud_efficiency" - choices: ["cloud_efficiency", "cloud_ssd"] - system_disk_size: - description: - - Size of the system disk, in GB - default: 40 - choices: [40~500] - system_disk_name: - description: - - Name of the system disk. - system_disk_description: - description: - - Description of the system disk. - count: - description: - - The number of the new instance. An integer value which indicates how many instances that match I(count_tag) - should be running. Instances are either created or terminated based on this value. - default: 1 - count_tag: - description: - - I(count) determines how many instances based on a specific tag criteria should be present. - This can be expressed in multiple ways and is shown in the EXAMPLES section. - The specified count_tag must already exist or be passed in as the I(instance_tags) option. - If it is not specified, it will be replaced by I(instance_name). - allocate_public_ip: - description: - - Whether allocate a public ip for the new instance. - default: False - aliases: [ 'assign_public_ip' ] - type: bool - instance_charge_type: - description: - - The charge type of the instance. - choices: ["PrePaid", "PostPaid"] - default: "PostPaid" - period: - description: - - The charge duration of the instance. Required when C(instance_charge_type=PrePaid). - choices: [1~9,12,24,36] - default: 1 - auto_renew: - description: - - Whether automate renew the charge of the instance. - type: bool - default: False - auto_renew_period: - description: - - The duration of the automatic renew the charge of the instance. Required when C(auto_renew=True). - choices: [1, 2, 3, 6, 12] - instance_ids: - description: - - A list of instance ids. It is required when need to operate existing instances. - If it is specified, I(count) will lose efficacy. - force: - description: - - Whether the current operation needs to be execute forcibly. - default: False - type: bool - instance_tags: - description: - - A hash/dictionaries of instance tags, to add to the new instance or for starting/stopping instance by tag. C({"key":"value"}) - aliases: ["tags"] - sg_action: - description: - - The action of operating security group. - choices: ['join', 'leave'] - key_name: - description: - - The name of key pair which is used to access ECS instance in SSH. - required: false - aliases: ['keypair'] - user_data: - description: - - User-defined data to customize the startup behaviors of an ECS instance and to pass data into an ECS instance. - It only will take effect when launching the new ECS instances. - required: false -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# basic provisioning example vpc network -- name: basic provisioning example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - image: ubuntu1404_64_40G_cloudinit_20160727.raw - instance_type: ecs.n4.small - vswitch_id: vsw-abcd1234 - assign_public_ip: True - max_bandwidth_out: 10 - host_name: myhost - password: mypassword - system_disk_category: cloud_efficiency - system_disk_size: 100 - internet_charge_type: PayByBandwidth - group_id: sg-f2rwnfh23r - sg_action: join - - instance_ids: ["i-abcd12346", "i-abcd12345"] - force: True - - tasks: - - name: launch ECS instance in VPC network - alicloud_instance: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - image: '{{ image }}' - system_disk_category: '{{ system_disk_category }}' - system_disk_size: '{{ system_disk_size }}' - instance_type: '{{ instance_type }}' - vswitch_id: '{{ vswitch_id }}' - assign_public_ip: '{{ assign_public_ip }}' - internet_charge_type: '{{ internet_charge_type }}' - max_bandwidth_out: '{{ max_bandwidth_out }}' - instance_tags: - Name: created_one - host_name: '{{ host_name }}' - password: '{{ password }}' - - - name: with count and count_tag to create a number of instances - alicloud_instance: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - image: '{{ image }}' - system_disk_category: '{{ system_disk_category }}' - system_disk_size: '{{ system_disk_size }}' - instance_type: '{{ instance_type }}' - assign_public_ip: '{{ assign_public_ip }}' - group_id: '{{ group_id }}' - internet_charge_type: '{{ internet_charge_type }}' - max_bandwidth_out: '{{ max_bandwidth_out }}' - instance_tags: - Name: created_one - Version: 0.1 - count: 2 - count_tag: - Name: created_one - host_name: '{{ host_name }}' - password: '{{ password }}' - - - name: start instance - alicloud_instance: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance_ids }}' - state: 'running' - - - name: reboot instance forcibly - ecs: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance_ids }}' - state: 'restarted' - force: '{{ force }}' - - - name: Add instances to an security group - ecs: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance_ids }}' - group_id: '{{ group_id }}' - sg_action: '{{ sg_action }}' -''' - -RETURN = ''' -instance_ids: - description: List all instances's id after operating ecs instance. - returned: expect absent - type: list - sample: ["i-35b333d9","i-ddavdaeb3"] -instance_ips: - description: List all instances's public ip address after operating ecs instance. - returned: expect absent - type: list - sample: ["10.1.1.1","10.1.1.2"] -instance_names: - description: List all instances's name after operating ecs instance. - returned: expect absent - type: list - sample: ["MyInstane","MyInstane2"] -total: - description: The number of all instances after operating ecs instance. - returned: expect absent - type: int - sample: 2 -''' - -import time -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_public_ip(instance): - if instance.public_ip_address: - return instance.public_ip_address - elif instance.eip: - return instance.eip - return "" - - -def create_instance(module, ecs, exact_count): - """ - create an instance in ecs - """ - if exact_count <= 0: - return None - zone_id = module.params['alicloud_zone'] - image_id = module.params['image_id'] - instance_type = module.params['instance_type'] - group_id = module.params['group_id'] - vswitch_id = module.params['vswitch_id'] - instance_name = module.params['instance_name'] - description = module.params['description'] - internet_charge_type = module.params['internet_charge_type'] - max_bandwidth_out = module.params['max_bandwidth_out'] - max_bandwidth_in = module.params['max_bandwidth_out'] - host_name = module.params['host_name'] - password = module.params['password'] - system_disk_category = module.params['system_disk_category'] - system_disk_size = module.params['system_disk_size'] - system_disk_name = module.params['system_disk_name'] - system_disk_description = module.params['system_disk_description'] - allocate_public_ip = module.params['allocate_public_ip'] - instance_tags = module.params['instance_tags'] - period = module.params['period'] - auto_renew = module.params['auto_renew'] - instance_charge_type = module.params['instance_charge_type'] - auto_renew_period = module.params['auto_renew_period'] - user_data = module.params['user_data'] - key_name = module.params['key_name'] - - # check whether the required parameter passed or not - if not image_id: - module.fail_json(msg='image_id is required for new instance') - if not instance_type: - module.fail_json(msg='instance_type is required for new instance') - - client_token = "Ansible-Alicloud-%s-%s" % (hash(str(module.params)), str(time.time())) - - try: - # call to create_instance method from footmark - instances = ecs.create_instance(image_id=image_id, instance_type=instance_type, group_id=group_id, - zone_id=zone_id, instance_name=instance_name, description=description, - internet_charge_type=internet_charge_type, max_bandwidth_out=max_bandwidth_out, - max_bandwidth_in=max_bandwidth_in, host_name=host_name, password=password, - io_optimized='optimized', system_disk_category=system_disk_category, - system_disk_size=system_disk_size, system_disk_name=system_disk_name, - system_disk_description=system_disk_description, - vswitch_id=vswitch_id, count=exact_count, allocate_public_ip=allocate_public_ip, - instance_charge_type=instance_charge_type, period=period, auto_renew=auto_renew, - auto_renew_period=auto_renew_period, instance_tags=instance_tags, - key_pair_name=key_name, user_data=user_data, client_token=client_token) - - except Exception as e: - module.fail_json(msg='Unable to create instance, error: {0}'.format(e)) - - return instances - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - group_id=dict(type='str', aliases=['security_group_id']), - alicloud_zone=dict(type='str', aliases=['zone_id', 'zone']), - instance_type=dict(type='str', aliases=['type']), - image_id=dict(type='str', aliases=['image']), - count=dict(type='int', default=1), - count_tag=dict(type='str'), - vswitch_id=dict(type='str', aliases=['subnet_id']), - instance_name=dict(type='str', aliases=['name']), - host_name=dict(type='str'), - password=dict(type='str', no_log=True), - internet_charge_type=dict(type='str', default="PayByBandwidth", choices=["PayByBandwidth", "PayByTraffic"]), - max_bandwidth_in=dict(type='int', default=200), - max_bandwidth_out=dict(type='int', default=0), - system_disk_category=dict(type='str', default='cloud_efficiency'), - system_disk_size=dict(type='int', default='40'), - system_disk_name=dict(type='str'), - system_disk_description=dict(type='str'), - force=dict(type='bool', default=False), - instance_tags=dict(type='dict', aliases=['tags']), - state=dict(default='present', choices=['present', 'running', 'stopped', 'restarted', 'absent']), - description=dict(type='str'), - allocate_public_ip=dict(type='bool', aliases=['assign_public_ip'], default=False), - instance_charge_type=dict(type='str', default='PostPaid'), - period=dict(type='int', default=1), - auto_renew=dict(type='bool', default=False), - instance_ids=dict(type='list'), - sg_action=dict(type='str'), - auto_renew_period=dict(type='int'), - key_name=dict(type='str', aliases=['keypair']), - user_data=dict(type='str') - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="Package 'footmark' required for the module alicloud_instance.") - - ecs = ecs_connect(module) - state = module.params['state'] - instance_ids = module.params['instance_ids'] - count_tag = module.params['count_tag'] - count = module.params['count'] - instance_name = module.params['instance_name'] - force = module.params['force'] - zone_id = module.params['alicloud_zone'] - key_name = module.params['key_name'] - changed = False - - instances = [] - if instance_ids: - if not isinstance(instance_ids, list): - module.fail_json(msg='The parameter instance_ids should be a list, aborting') - instances = ecs.get_all_instances(zone_id=zone_id, instance_ids=instance_ids) - if not instances: - module.fail_json(msg="There are no instances in our record based on instance_ids {0}. " - "Please check it and try again.".format(instance_ids)) - elif count_tag: - instances = ecs.get_all_instances(zone_id=zone_id, instance_tags=eval(count_tag)) - elif instance_name: - instances = ecs.get_all_instances(zone_id=zone_id, instance_name=instance_name) - - ids = [] - ips = [] - names = [] - if state == 'present': - if not instance_ids: - if len(instances) > count: - for i in range(0, len(instances) - count): - inst = instances[len(instances) - 1] - if inst.status is not 'stopped' and not force: - module.fail_json(msg="That to delete instance {0} is failed results from it is running, " - "and please stop it or set 'force' as True.".format(inst.id)) - try: - changed = inst.terminate(force=force) - except Exception as e: - module.fail_json(msg="Delete instance {0} got an error: {1}".format(inst.id, e)) - instances.pop(len(instances) - 1) - else: - try: - new_instances = create_instance(module, ecs, count - len(instances)) - if new_instances: - changed = True - instances.extend(new_instances) - except Exception as e: - module.fail_json(msg="Create new instances got an error: {0}".format(e)) - - # Security Group join/leave begin - sg_action = module.params['sg_action'] - - if sg_action: - action = sg_action.strip().lower() - - if action not in ('join', 'leave'): - module.fail_json(msg='To perform join_security_group or leave_security_group operation,' - 'sg_action must be either join or leave respectively') - - security_group_id = module.params['group_id'] - for inst in instances: - # Adding an Instance to a Security Group - if action == 'join': - if security_group_id not in inst.security_group_ids['security_group_id']: - changed = inst.join_security_group(security_group_id) - else: - if security_group_id in inst.security_group_ids['security_group_id']: - changed = inst.leave_security_group(security_group_id) - - # Security Group join/leave ends here - - # Attach/Detach key pair - inst_ids = [] - for inst in instances: - if key_name is not None and key_name != inst.key_name: - if key_name == "": - changed = inst.detach_key_pair() - else: - inst_ids.append(inst.id) - if inst_ids: - changed = ecs.attach_key_pair(instance_ids=inst_ids, key_pair_name=key_name) - - # Modify instance attribute - description = module.params['description'] - host_name = module.params['host_name'] - password = module.params['password'] - for inst in instances: - update = False - if instance_name and instance_name != inst.name: - update = True - else: - name = inst.name - if description and description != inst.description: - update = True - else: - description = inst.description - if host_name and host_name != inst.host_name: - update = True - else: - host_name = inst.host_name - if password: - update = True - - if update: - try: - changed = inst.modify(name=name, description=description, host_name=host_name, password=password) - except Exception as e: - module.fail_json(msg="Modify instance attribute {0} got an error: {1}".format(inst.id, e)) - - if inst.id not in ids: - ids.append(inst.id) - names.append(inst.name) - ip = get_public_ip(inst) - if ip not in ips: - ips.append(ip) - - module.exit_json(changed=changed, instance_ids=ids, instance_ips=ips, instance_names=names, total=len(ids)) - - else: - if len(instances) < 1: - module.fail_json(msg='Please specify ECS instances that you want to operate by using ' - 'parameters instance_ids, instance_tags or instance_name, aborting') - force = module.params['force'] - if state == 'running': - try: - for inst in instances: - changed = inst.start() - if changed: - ids.append(inst.id) - names.append(inst.name) - ips.append(get_public_ip(inst)) - - module.exit_json(changed=changed, instance_ids=ids, instance_ips=ips, instance_names=names, total=len(ids)) - except Exception as e: - module.fail_json(msg='Start instances got an error: {0}'.format(e)) - elif state == 'stopped': - try: - for inst in instances: - changed = inst.stop(force=force) - if changed: - ids.append(inst.id) - names.append(inst.name) - ips.append(get_public_ip(inst)) - - module.exit_json(changed=changed, instance_ids=ids, instance_ips=ips, instance_names=names, total=len(ids)) - except Exception as e: - module.fail_json(msg='Stop instances got an error: {0}'.format(e)) - elif state == 'restarted': - try: - for inst in instances: - changed = inst.reboot(force=module.params['force']) - if changed: - ids.append(inst.id) - names.append(inst.name) - ips.append(get_public_ip(inst)) - - module.exit_json(changed=changed, instance_ids=ids, instance_ips=ips, instance_names=names, total=len(ids)) - except Exception as e: - module.fail_json(msg='Reboot instances got an error: {0}'.format(e)) - else: - try: - for inst in instances: - if inst.status is not 'stopped' and not force: - module.fail_json(msg="Instance is running, and please stop it or set 'force' as True.") - changed = inst.terminate(force=module.params['force']) - - module.exit_json(changed=changed) - except Exception as e: - module.fail_json(msg='Delete instance got an error: {0}'.format(e)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_instance_facts.py b/lib/ansible/modules/cloud/alicloud/_alicloud_instance_facts.py deleted file mode 100644 index 1afafc4e..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_instance_facts.py +++ /dev/null @@ -1,248 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_instance_facts -version_added: "1.0.9" -short_description: Gather facts on instances of Alibaba Cloud ECS. -description: - - This module fetches data from the Open API in Alicloud. - The module must be called from within the ECS instance itself. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_instance_facts) instead. -options: - alicloud_zone: - description: - - Aliyun availability zone ID in which to launch the instance - aliases: [ 'zone_id', 'zone' ] - instance_names: - description: - - A list of ECS instance names. - aliases: [ "names"] - instance_ids: - description: - - A list of ECS instance ids. - aliases: ["ids"] - instance_tags: - description: - - A hash/dictionaries of instance tags. C({"key":"value"}) - aliases: ["tags"] -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Fetch instances details according to setting different filters -- name: fetch instances details example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-a - - tasks: - - name: Find all instances in the specified region - alicloud_instance_facts: - register: all_instances - - name: Find all instances based on the specified ids - alicloud_instance_facts: - instance_ids: - - "i-35b333d9" - - "i-ddav43kd" - register: instances_by_ids - - name: Find all instances based on the specified names/name-prefixes - alicloud_instance_facts: - instance_names: - - "ecs_instance-1" - - "ecs_instance_2" - register: instances_by_ids - -''' - -RETURN = ''' -instance_ids: - description: List all instances's id after operating ecs instance. - returned: when success - type: list - sample: ["i-2ze9zfjdhtasdrfbgay1"] -instances: - description: Details about the ecs instances that were created. - returned: when success - type: list - sample: [{ - "block_device_mapping": { - "d-2ze9mho1vp79mctdoro0": { - "delete_on_termination": true, - "status": "in_use", - "volume_id": "d-2ze9mho1vp79mctdoro0" - } - }, - "eip": { - "allocation_id": "", - "internet_charge_type": "", - "ip_address": "" - }, - "group_ids": { - "security_group_id": [ - "sg-2zegcq33l0yz9sknp08o" - ] - }, - "host_name": "myhost", - "id": "i-2ze9zfjdhtasdrfbgay1", - "image_id": "ubuntu1404_64_40G_cloudinit_20160727.raw", - "instance_name": "test-instance", - "instance_type": "ecs.n1.small", - "io_optimized": true, - "key_name": "test", - "launch_time": "2017-05-23T00:56Z", - "private_ip": "10.31.153.209", - "public_ip": "47.94.45.175", - "region_id": "cn-beijing", - "status": "running", - "tags": { - "create_test": "0.01" - }, - "vpc_attributes": { - "nat_ip_address": "", - "private_ip_address": { - "ip_address": [] - }, - "vpc_id": "", - "vswitch_id": "" - }, - "zone_id": "cn-beijing-a" - }] -total: - description: The number of all instances after operating ecs instance. - returned: when success - type: int - sample: 1 -''' - -# import time -# import sys -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, ecs_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_instance_info(inst): - """ - Retrieves instance information from an instance - ID and returns it as a dictionary - """ - instance_info = {'id': inst.id, - 'private_ip': inst.inner_ip_address, - 'public_ip': inst.public_ip_address, - 'image_id': inst.image_id, - 'zone_id': inst.zone_id, - 'region_id': inst.region_id, - 'launch_time': inst.creation_time, - 'instance_type': inst.instance_type, - 'instance_name': inst.instance_name, - 'host_name': inst.host_name, - 'group_ids': inst.security_group_ids, - 'status': inst.status, - 'tags': inst.tags, - 'vpc_attributes': inst.vpc_attributes, - 'eip': inst.eip_address, - 'io_optimized': inst.io_optimized, - 'key_name': inst.key_name - } - try: - bdm_dict = {} - bdm = getattr(inst, 'block_device_mapping') - for device_name in bdm.keys(): - bdm_dict[device_name] = { - 'status': bdm[device_name].status, - 'volume_id': bdm[device_name].volume_id, - 'delete_on_termination': bdm[device_name].delete_on_termination - } - instance_info['block_device_mapping'] = bdm_dict - except AttributeError: - instance_info['block_device_mapping'] = False - - return instance_info - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - alicloud_zone=dict(aliases=['zone_id', 'zone']), - instance_ids=dict(type='list', aliases=['ids']), - instance_names=dict(type='list', aliases=['names']), - instance_tags=dict(type='list', aliases=['tags']), - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module alicloud_instance_facts') - - ecs = ecs_connect(module) - - instances = [] - instance_ids = [] - ids = module.params['instance_ids'] - names = module.params['instance_names'] - zone_id = module.params['alicloud_zone'] - if ids and (not isinstance(ids, list) or len(ids)) < 1: - module.fail_json(msg='instance_ids should be a list of instances, aborting') - - if names and (not isinstance(names, list) or len(names)) < 1: - module.fail_json(msg='instance_ids should be a list of instances, aborting') - - if names: - for name in names: - for inst in ecs.get_all_instances(zone_id=zone_id, instance_ids=ids, instance_name=name): - instances.append(get_instance_info(inst)) - instance_ids.append(inst.id) - else: - for inst in ecs.get_all_instances(zone_id=zone_id, instance_ids=ids): - instances.append(get_instance_info(inst)) - instance_ids.append(inst.id) - - module.exit_json(changed=False, instance_ids=instance_ids, instances=instances, total=len(instances)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_instance_type_facts.py b/lib/ansible/modules/cloud/alicloud/_alicloud_instance_type_facts.py deleted file mode 100644 index 7597d017..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_instance_type_facts.py +++ /dev/null @@ -1,226 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_instance_type_facts -version_added: "1.0.9" -short_description: Gather facts of instance types provided by Alibaba Cloud ECS. -description: - - This module fetches data from the Open API in Alicloud. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_instance_type_facts) instead. -options: - alicloud_zone: - description: - - The Zone that supports available instance types. - aliases: ['zone_id', 'zone'] - instance_type_ids: - description: - - List Ids of instance types. - aliases: ['ids'] - instance_type_families: - description: - - List family names of instance types. - aliases: ['families'] - cpu_core_count: - description: - - Cpu core count of instance type. - aliases: ['cpu_count'] - memory_size: - description: - - Memory size of instance type. - aliases: ['memory'] -author: - - "He Guimin (@xiaozhu36)" -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -''' - -EXAMPLES = ''' -# Fetch instance types according to setting different filters -- name: fetch instance types example - hosts: localhost - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-a - - tasks: - - name: Find all instance types in the specified region - alicloud_instance_type_facts: - alicloud_region: '{{ alicloud_region }}' - register: all_instance_types - - name: Find all instance types based on the specified zone - alicloud_instance_type_facts: - alicloud_region: '{{ alicloud_region }}' - alicloud_zone: '{{ alicloud_zone }}' - register: instance_types_by_zone - - name: Find all instance types based on the specified family names - alicloud_instance_type_facts: - alicloud_region: '{{ alicloud_region }}' - instance_type_families: - - "ecs.gn5" - - "ecs.sn2ne" - register: instance_types_by_families - - name: Find all instance types based on the specified ids - alicloud_instance_type_facts: - alicloud_region: '{{ alicloud_region }}' - instance_type_ids: - - "ecs.se1ne.14xlarge" - - "ecs.m2.xlarge" - register: instance_types_by_ids - - name: Find all instance types based on the specified cpu core count - alicloud_instance_type_facts: - alicloud_region: '{{ alicloud_region }}' - cpu_core_count: 56 - register: instance_types_by_cpu - - name: Find all instance types based on the specified memory size - alicloud_instance_type_facts: - alicloud_region: '{{ alicloud_region }}' - memory_size: 64.0 - register: instance_types_by_memory -''' - -RETURN = ''' -instance_type_ids: - description: List ids of the instance types. - returned: when success - type: list - sample: ["ecs.m1.medium", "ecs.m1.xlarge"] -instance_types: - description: Details about the ecs instance types. - returned: when success - type: list - sample: [{ - "cpu_core_count": 4, - "id": "ecs.m1.medium", - "instance_type_family": "ecs.m1", - "memory_size": 16.0 - }, - { - "cpu_core_count": 8, - "id": "ecs.m1.xlarge", - "instance_type_family": "ecs.m1", - "memory_size": 32.0 - }] -total: - description: The number of all instance types. - returned: when success - type: int - sample: 2 -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, ecs_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import ECSResponseError - - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_instance_type_info(inst_type): - """ - Retrieves instance type information - returns it as a dictionary - """ - return { - 'id': inst_type.id, - 'cpu_core_count': inst_type.cpu_core_count, - 'memory_size': inst_type.memory_size, - 'instance_type_family': inst_type.family, - } - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update( - dict( - alicloud_zone=dict(aliases=['zone_id', 'zone']), - instance_type_ids=dict(type='list', aliases=["ids"]), - instance_type_families=dict(type='list', aliases=["families"]), - cpu_core_count=dict(type='int', aliases=["cpu_count"]), - memory_size=dict(type='float', aliases=["memory"]), - ) - ) - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module alicloud_instance_type_facts') - - ecs = ecs_connect(module) - - instance_types = [] - ids = [] - - zone_id = module.params["alicloud_zone"] - instance_type_ids = module.params["instance_type_ids"] - instance_type_families = module.params["instance_type_families"] - cpu_core_count = module.params["cpu_core_count"] - memory_size = module.params["memory_size"] - - if zone_id: - zones = ecs.describe_zones(zone_id=zone_id) - families = [f for z in zones for resource in z.available_resources["resources_info"] for f in resource["instance_type_families"]["supported_instance_type_family"]] - - if instance_type_families: - filter_families = [f for f in instance_type_families if f in families] - if not filter_families: - module.fail_json(msg="Instance type families {0} is not supported in the zone {1}. Expected instance type families: {2}.".format(instance_type_families, zone_id, families)) - families = filter_families - - families = list(set(families)) - else: - families = [f.id for f in ecs.describe_instance_type_families() if not instance_type_families or f.id in instance_type_families] - - for family in families: - for instance_type in ecs.describe_instance_types(instance_type_family=family): - if cpu_core_count and instance_type.cpu_core_count != cpu_core_count: - continue - if memory_size and instance_type.memory_size != memory_size: - continue - if instance_type_ids and instance_type.id not in instance_type_ids: - continue - instance_types.append(get_instance_type_info(instance_type)) - ids.append(instance_type.id) - - module.exit_json(changed=False, instance_type_ids=ids, instance_types=instance_types, - total=len(instance_types)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_rds_account.py b/lib/ansible/modules/cloud/alicloud/_alicloud_rds_account.py deleted file mode 100644 index ab2ee3d4..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_rds_account.py +++ /dev/null @@ -1,379 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: alicloud_rds_account -version_added: "1.0.9" -short_description: Create, Delete, Modyfy, Reset rds account, Grant or Revoke privilege. -description: - - This module allows the user to manage rds account. Includes support for creating, deleting, - reseting and modifying rds account, granting or revoking privilege. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_rds_account) instead. -options: - state: - description: - - The state of the account after operating. - default: present - choices: [ 'present', 'absent'] - db_instance_id: - description: - - Id of rds instance. - required: true - account_name: - description: - - Operation account requiring a uniqueness check. - It may consist of lower case letters, numbers and underlines, and must start with a letter and have no more than 16 characters. - required: true - aliases: ['name'] - account_password: - description: - - Operation password. It may consist of letters, digits, or underlines, with a length of 6 to 32 characters, Required when C(account_password != "") - aliases: ['password'] - description: - description: - - Account remarks, which cannot exceed 256 characters. It cannot begin with http:// , https:// . - It must start with a Chinese character or English letter. It can include Chinese and - English characters/letters, underlines (_), hyphens (-), and numbers. The length may be 2-256 characters, - account_type: - description: - - Privilege type of account. Normal for Common privilege; Super for High privilege; Default value is Normal. - This parameter is valid for MySQL 5.5/5.6 only - default: Normal - aliases: ['type'] - choices: [ 'Normal', 'Super'] - db_name: - description: - - Name of the database associated with this account, Required when C(db_name != ""). - account_privilege: - description: - - Account permission.Required when C(account_privilege != "") - aliases: ['privilege'] - choices: ['ReadOnly', 'ReadWrite'] -author: - - "Li Qiang" -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -""" - -EXAMPLES = """ -# basic provisioning example to create account -- name: create account - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - db_instance_id: - account_name: test - account_password: rohit@123 - description: normal account - account_type: normal - tasks: - - name: create account - ali_rds_account: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - state: present - db_instance_id: '{{ db_instance_id }}' - account_name: '{{ account_name }}' - account_password: '{{ account_password }}' - description: '{{ description }}' - account_type: '{{ account_type }}' - register: result - - debug: var=result - -# basic provisioning example to modify account description -- name: modify description - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - db_instance_id: - account_name: test - description: normal account - tasks: - - name: modify description - ali_rds_account: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - state: present - db_instance_id: '{{ db_instance_id }}' - account_name: '{{ account_name }}' - description: '{{ description }}' - register: result - - debug: var=result - -# basic provisioning example to reset an account password -- name: Reset an account password - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-beijing - db_instance_id: - account_name: test - account_password: rohit@123 - tasks: - - name: reset an account password - ali_rds_account: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - state: present - db_instance_id: '{{ db_instance_id }}' - account_name: '{{ account_name }}' - account_password: '{{ account_password }}' - register: result - - debug: var=result - -# basic provisioning example to delete an account -- name: Delete account - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hongkong - state: absent - db_instance_id: - account_name: test - tasks: - - name: delete account - rds_account: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - state: present - db_instance_id: '{{ db_instance_id }}' - account_name: '{{ account_name }}' - register: result - - debug: var=result - -# basic provisioning example to grant account permission -- name: grant account permission - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hongkong - db_instance_id: - db_name: test - account_name: account-test - account_privilege: ReadOnly - tasks: - - name: grant account permission - rds_account: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - state: present - db_instance_id: '{{ db_instance_id }}' - db_name: '{{ db_name }}' - account_name: '{{ account_name }}' - account_privilege: '{{ account_privilege }}' - register: result - - debug: var=result - -# basic provisioning example to revoke account permission -- name: revoke account permission - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: cn-hongkong - db_instance_id: - db_name: db-test - account_name: account-test - tasks: - - name: revoke account permission - rds_account: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - state: present - db_instance_id: '{{ db_instance_id }}' - db_name: '{{ db_name }}' - account_name: '{{ account_name }}' - register: result - - debug: var=result -""" - -RETURN = ''' -account: - description: account info. - returned: when success - type: dict - sample: { - "account_description": "", - "account_name": "testdemoaccount", - "account_status": "Available", - "account_type": "Normal", - "database_privileges": { - "database_privilege": [ - { - "account_privilege": "ReadOnly", - "dbname": "testtest" - } - ] - }, - "db_instance_id": "rm-2zey7ir50261bmg42" - } -account_name: - description: name of account. - returned: when success - type: str - sample: "testname" -''' - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, rds_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import RDSResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(obj): - """ - get info from account obj - :type obj: account object - :param obj: the object of account - :return: dict of account info - """ - if obj: - return dict(db_instance_id=obj.dbinstance_id, - account_name=obj.account_name, - account_status=obj.account_status, - account_type=obj.account_type, - account_description=obj.account_description, - database_privileges=obj.database_privileges) - return {} - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - state=dict(default='present', choices=['present', 'absent']), - db_name=dict(type='str'), - db_instance_id=dict(type='str', required=True), - account_name=dict(type='str', aliases=['name'], required=True), - account_password=dict(type='str', aliases=['password']), - account_privilege=dict(aliases=['privilege'], choices=['ReadOnly', 'ReadWrite']), - description=dict(type='str'), - account_type=dict(default='Normal', type='str', choices=['Normal', 'Super']), - )) - - module = AnsibleModule(argument_spec=argument_spec) - rds = rds_connect(module) - - if HAS_FOOTMARK is False: - module.fail_json("Footmark required for this module") - - # Get values of variable - state = module.params['state'] - db_instance_id = module.params['db_instance_id'] - account_name = module.params['account_name'] - account_password = module.params['account_password'] - account_privilege = module.params['account_privilege'] - description = module.params['description'] - account_type = module.params['account_type'] - db_name = module.params['db_name'] - - account_list = [] - current_account = None - changed = False - - try: - current_account_list = rds.list_account(db_instance_id, account_name) - if len(current_account_list) == 1: - current_account = current_account_list[0] - except Exception as e: - module.fail_json(msg=str("Unable to describe accounts, error:{0}".format(e))) - - if state == "absent": - if current_account: - if db_name: - try: - changed = current_account.revoke_privilege(db_instance_id, db_name) - current_account = rds.list_account(db_instance_id, account_name)[0] - module.exit_json(changed=True, account_name=account_name, account=get_info(current_account)) - except Exception as e: - module.fail_json(msg=str("Unable to revoke privilege error:{0}".format(e))) - try: - changed = current_account.delete(db_instance_id) - module.exit_json(changed=True, account_name=account_name, account=get_info(current_account)) - except Exception as e: - module.fail_json(msg=str("Unable to delete account error:{0}".format(e))) - module.fail_json(msg="There is no account to revoke database privilege or delete. Please specify an account using 'account_name', and try again.") - if account_password and current_account: - try: - changed = current_account.reset(db_instance_id, account_password) - except Exception as e: - module.fail_json(msg=str("Unable to reset account password error:{0}".format(e))) - if not current_account: - try: - current_account = rds.create_account(db_instance_id, account_name, account_password, description, account_type) - except Exception as e: - module.fail_json(msg=str("Unable to create account error:{0}".format(e))) - if description and description != current_account.account_description: - try: - changed = current_account.modify_description(db_instance_id, description) - current_account.account_description = description - except Exception as e: - module.fail_json(msg=str("Unable to modify account description error:{0}".format(e))) - if db_name: - if account_privilege: - try: - changed = current_account.grant_privilege(db_instance_id, db_name, account_privilege) - current_account = current_account_list[0] - except Exception as e: - module.fail_json(msg=str("Unable to grant privilege error:{0}".format(e))) - else: - module.fail_json(msg="grant privilege failed. Please check your account_privilege and try again.") - module.exit_json(changed=changed, account_name=account_name, account=get_info(current_account)) - - -if __name__ == "__main__": - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_route_entry.py b/lib/ansible/modules/cloud/alicloud/_alicloud_route_entry.py deleted file mode 100644 index 7617cec3..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_route_entry.py +++ /dev/null @@ -1,324 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: alicloud_route_entry -version_added: "1.0.9" -short_description: Manage route entry for Alicloud virtual private cloud, -description: - - Manage route entry for Alicloud virtual private cloud. - Create or Delete route entry in one route table. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_route_entry) instead. -options: - state: - description: - - Whether or not to create, delete route entry. - choices: ['present', 'absent'] - default: 'present' - router_id: - description: - - The ID of virtual router to which route entry belongs. - required: true - destination_cidrblock: - description: - - The destination CIDR or Ip address of route entry. Such as:192.168.0.0/24 or 192.168.0.1. - There is not the same destination cidr_block in the same route table. It is required when creating route entry. - aliases: ['dest_cidrblock', 'cidr_block'] - nexthop_id: - description: - - The next hop ID of route entry. It is required when creating a route entry. - aliases: ['hop_id'] - nexthop_type: - description: - - The next hop type of route entry. - default: 'Instance' - choices: ['Instance', 'Tunnel', 'HaVip', 'RouterInterface', 'VpnGateway'] - aliases: ['hop_type'] -notes: - - The max items of route entry no more than 48 in the same route table. - - The destination_cidrblock can't have the same cidr block as vswitch and can't belong to its in the same vpc. - - The destination_cidrblock can't be 100.64.0.0/10 and can't belong to it. - - When state is 'list', the parameters 'route_table_id', 'destination_cidrblock' and 'nexthop_id' are optional. -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" -""" - -EXAMPLES = """ - -# basic provisioning example to create custom route -- name: create route entry - hosts: localhost - connection: local - vars: - alicloud_region: cn-hongkong - state: present - cidr_block: '192.168.4.0/24' - nexthop_id: 'xxxxxxxxxx' - router_id: 'XXXXXXXX' - tasks: - - name: create route entry - alicloud_route_entry: - alicloud_region: '{{ alicloud_region }}' - state: '{{ state }}' - destination_cidrblock: '{{ cidr_block }}' - nexthop_id: '{{ nexthop_id }}' - router_id: 'XXXXXXXX' - register: result - - debug: var=result - -# basic provisioning example to delete custom route -- name: delete route entry - hosts: localhost - connection: local - vars: - alicloud_region: cn-hongkong - destination_cidrblock: "192.168.4.0/24" - next_hop_id: "xxxxxxxxxx" - router_id: 'XXXXXXXX' - state: present - tasks: - - name: delete route - alicloud_route_entry: - alicloud_region: '{{ alicloud_region }}' - destination_cidrblock: '{{ cidr_block }}' - nexthop_id: '{{ nexthop_id }}' - router_id: 'XXXXXXXX' - state: '{{ state }}' - register: result - - debug: var=result - -# basic provisioning example to querying route entries -- name: get route entry list - hosts: localhost - connection: local - vars: - alicloud_region: cn-hongkong - router_id: xxxxxxxxxx - state: list - tasks: - - name: get vrouter list - alicloud_route_entry: - alicloud_region: '{{ alicloud_region }}' - router_id: '{{ router_id }}' - state: '{{ state }}' - register: result - - debug: var=result - -""" - -RETURN = ''' - -destination_cidrblock: - description: the destination CIDR block of route entry - returned: on present and absent - type: string - sample: "10.0.14.0/24" - -route_entry: - description: Details about the ecs route entry that was created. - returned: on present - type: dict - sample: { - "destination_cidrblock": "10.0.14.0/24", - "nexthop_id": "i-2zejbnp5zv525per4g84", - "nexthop_type": "Instance", - "route_table_id": "vtb-2zeeokge820zn0kqawmi9", - "status": "Available", - "type": "Custom" - } - -destination_cidrblocks: - description: the list destination CIDR blocks of route entries in one route table - returned: on list - type: list - sample: ["10.0.14.0/24", "10.0.13.0/24", "100.64.0.0/10"] - -"route_entries": - description: Details about the ecs route entries that were retrieved in one route table. - returned: on list - type: list - sample: [ - { - "destination_cidrblock": "10.0.14.0/24", - "nexthop_id": "i-2zejbnp5zv525per4g84", - "nexthop_type": "Instance", - "route_table_id": "vtb-2zeeokge820zn0kqawmi9", - "status": "Available", - "type": "Custom" - }, - { - "destination_cidrblock": "10.0.13.0/24", - "nexthop_id": "", - "nexthop_type": "local", - "route_table_id": "vtb-2zeeokge820zn0kqawmi9", - "status": "Available", - "type": "System" - } - ] -route_table_id: - description: the ID of route table to which route entry belongs - returned: on present and absent - type: string - sample: "vtb-2zemlj5nscgoicjnxes7h" -total: - description: The number of all route entries after retrieving route entry. - returned: on list - type: int - sample: 3 -''' - -# import module snippets -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import VPCResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_route_entry_basic(entry): - """ - Format vpc result and returns it as a dictionary - """ - return {'route_table_id': entry.route_table_id, 'destination_cidrblock': entry.destination_cidrblock} - - -def get_route_entry_detail(entry): - """ - Format vpc result and returns it as a dictionary - """ - return {'route_table_id': entry.route_table_id, 'destination_cidrblock': entry.destination_cidrblock, 'type': entry.type, - "nexthop_type": entry.nexthop_type, 'nexthop_id': entry.nexthop_id, 'status': entry.status} - - -def create_route_entry(module, vpc, route_table_id): - """ - Create VSwitch - :param module: Ansible module object - :param vpc: Authenticated vpc connection object - :return: Return details of created VSwitch - """ - destination_cidrblock = module.params['destination_cidrblock'] - nexthop_type = module.params['nexthop_type'] - nexthop_id = module.params['nexthop_id'] - - if not nexthop_id: - module.fail_json(msg='nexthop_id is required for creating a route entry.') - - if not destination_cidrblock: - module.fail_json(msg='destination_cidrblock is required for creating a route entry.') - - try: - route_entry = vpc.create_route_entry(route_table_id=route_table_id, destination_cidrblock=destination_cidrblock, - nexthop_type=nexthop_type, nexthop_id=nexthop_id) - return True, route_entry - except VPCResponseError as e: - module.fail_json(msg='Unable to create route entry, error: {0}'.format(e)) - - return False, None - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - state=dict(default='present', choices=['present', 'absent']), - destination_cidrblock=dict(type='str', aliases=['dest_cidrblock', 'cidr_block']), - nexthop_type=dict(default='Instance', aliases=['hop_type'], choices=['Instance', 'Tunnel', 'HaVip', 'RouterInterface']), - nexthop_id=dict(aliases=['hop_id']), - router_id=dict(type='str', required=True), - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module alicloud_route_entry.') - - vpc = vpc_connect(module) - - # Get values of variable - state = module.params['state'] - destination_cidrblock = module.params['destination_cidrblock'] - router_id = module.params['router_id'] - nexthop_id = module.params['nexthop_id'] - route_table_id = None - - changed = False - route_entries = [] - route_entries_basic = [] - route_entry = None - - try: - page = 1 - pagesize = 50 - while True: - entries = vpc.get_all_route_entries(router_id=router_id, router_type='VRouter', pagenumber=page, pagesize=pagesize) - if entries and len(entries) > 0: - for entry in entries: - route_table_id = entry.route_table_id - route_entries.append(entry) - route_entries_basic.append(get_route_entry_basic(entry)) - - if destination_cidrblock and entry.destination_cidrblock == destination_cidrblock: - route_entry = entry - - if not entries or len(entries) < pagesize: - break - page += 1 - - except VPCResponseError as e: - module.fail_json(msg='Unable to retrieve route entries, error: {0}'.format(e)) - - if state == 'present': - if not route_entry: - changed, route_entry = create_route_entry(module, vpc, route_table_id) - - module.exit_json(changed=changed, route_table_id=route_table_id, route_entry=get_route_entry_detail(route_entry), - destination_cidrblock=route_entry.destination_cidrblock) - - else: - if route_entry: - try: - changed = vpc.delete_route_entry(route_table_id, destination_cidrblock=destination_cidrblock, nexthop_id=nexthop_id) - except VPCResponseError as e: - module.fail_json(msg='Unable to delete route entry, error: {0}'.format(e)) - module.exit_json(changed=changed, route_table_id=route_table_id, destination_cidrblock=destination_cidrblock) - - module.exit_json(changed=changed, msg="Please specify a route entry by using 'destination_cidrblock'," - "and expected vpcs: {0}".format(route_entries_basic)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_security_group.py b/lib/ansible/modules/cloud/alicloud/_alicloud_security_group.py deleted file mode 100644 index 307e6688..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_security_group.py +++ /dev/null @@ -1,618 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_security_group -version_added: "1.0.9" -short_description: Create, Query or Delete Security Group. -description: - - Create and Delete Security Group, and it contains security group rules management. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_security_group) instead. -options: - state: - description: - - Create, delete a security group - default: 'present' - choices: ['present', 'absent'] - group_name: - description: - - Name of the security group, which is a string of 2 to 128 Chinese or English characters. It must begin with an - uppercase/lowercase letter or a Chinese character and can contain numerals, "_", "." or "-". - It cannot begin with http:// or https://. - aliases: ['name'] - description: - description: - - Description of the security group, which is a string of 2 to 256 characters. - - It cannot begin with http:// or https://. - vpc_id: - description: - - ID of the VPC to which the security group belongs. - rules: - description: - - List of hash/dictionaries firewall inbound rules to enforce in this group. - suboptions: - ip_protocol: - description: - - IP protocol - required: true - choices: ["tcp", "udp", "icmp", "gre", "all"] - aliases: ['proto'] - port_range: - description: - - The range of port numbers. Tcp and udp's valid range is 1 to 65535, and other protocol's valid value is -1/-1. - required: true - source_group_id: - description: - - The source security group id. - aliases: ['group_id'] - source_group_owner_id: - description: - - The source security group owner id. - aliases: ['group_owner_id'] - source_cidr_ip: - description: - - The source IP address range - aliases: ['cidr_ip'] - policy: - description: - - Authorization policy - default: "accept" - choices: ["accept", "drop"] - priority: - description: - - Authorization policy priority - default: 1 - choices: ["1~100"] - nic_type: - description: - - Network type - default: "internet" - choices: ["internet", "intranet"] - rules_egress: - description: - - List of hash/dictionaries firewall outbound rules to enforce in this group. - Keys allowed are:ip_protocol, port_range, dest_group_id, dest_group_owner_id, dest_cidr_ip, policy, priority,nic_type. - And these keys's attribution same as rules keys. - suboptions: - ip_protocol: - description: - - IP protocol - required: true - choices: ["tcp", "udp", "icmp", "gre", "all"] - aliases: ['proto'] - port_range: - description: - - The range of port numbers. Tcp and udp's valid range is 1 to 65535, and other protocol's valid value is "-1/-1". - required: true - dest_group_id: - description: - - The destination security group id. - aliases: ['group_id'] - dest_group_owner_id: - description: - - The destination security group owner id. - aliases: ['group_owner_id'] - dest_cidr_ip: - description: - - The destination IP address range - aliases: ['cidr_ip'] - policy: - description: - - Authorization policy - default: "accept" - choices: ["accept", "drop"] - priority: - description: - - Authorization policy priority - default: 1 - choices: ["1~100"] - nic_type: - description: - - Network type - default: "internet" - choices: ["internet", "intranet"] - group_id: - description: - - Security group ID. It is required when deleting or querying security group or performing rules authorization. -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" -''' - -EXAMPLES = ''' -# -# Provisioning new Security Group -# - -# Basic provisioning example to create security group -- name: create security group - hosts: localhost - connection: local - vars: - alicloud_access_key: xxxxxxxxxx - alicloud_secret_key: xxxxxxxxxx - alicloud_region: cn-shenzhen - tasks: - - name: create security grp - alicloud_security_group: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - group_name: 'AliyunSG' - - -# Basic provisioning example authorize security group -- name: authorize security grp - hosts: localhost - connection: local - vars: - alicloud_access_key: xxxxxxxxxx - alicloud_secret_key: xxxxxxxxxx - alicloud_region: cn-shenzhen - tasks: - - name: authorize security group - alicloud_security_group: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - group_id: xxxxxxxxxx - alicloud_region: '{{ alicloud_region }}' - rules: - - ip_protocol: tcp - port_range: 1/122 - source_cidr_ip: '10.159.6.18/12' - rules_egress: - - proto: all - port_range: -1/-1 - dest_group_id: xxxxxxxxxx - nic_type: intranet - - -# Provisioning example create and authorize security group -- name: create and authorize security group - hosts: localhost - connection: local - vars: - alicloud_access_key: xxxxxxxxxx - alicloud_secret_key: xxxxxxxxxx - alicloud_region: cn-shenzhen - tasks: - - name: create and authorize security grp - alicloud_security_group: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - group_name: 'AliyunSG' - description: 'an example ECS group' - alicloud_region: '{{ alicloud_region }}' - rules: - - ip_protocol: tcp - port_range: 1/122 - source_cidr_ip: '10.159.6.18/12' - priority: 10 - policy: drop - nic_type: intranet - rules_egress: - - proto: all - port_range: -1/-1 - dest_group_id: xxxxxxxxxx - group_owner_id: xxxxxxxxxx - priority: 10 - policy: accept - nic_type: intranet - - -# Provisioning example to delete security group -- name: delete security grp - hosts: localhost - connection: local - vars: - alicloud_access_key: xxxxxxxxxx - alicloud_secret_key: xxxxxxxxxx - alicloud_region: us-west-1 - group_ids: - - xxxxxxxxxx - state: absent - tasks: - - name: delete security grp - alicloud_security_group: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - group_ids: '{{ group_ids }}' - state: '{{ state }}' - -''' - -RETURN = ''' -group_id: - description: Deprecated from version 1.3.1 and replaced by 'id'. - returned: - type: - sample: -id: - description: ID of the security group. - returned: when present - type: string - sample: "sd-safhi3gsv" -name: - description: Name of the security group. - returned: when present - type: string - sample: "new-group" -group: - description: Details about the security group that was created - returned: when present - type: dict - sample: { - "description": "travis-ansible-instance", - "id": "sg-2ze1hhyn7tac4p85gh13", - "name": "travis-ansible-instance", - "region_id": "cn-beijing", - "rules": [ - { - "create_time": "2017-06-19T02:43:29Z", - "description": "", - "dest_cidr_ip": "", - "dest_group_id": "", - "dest_group_name": "", - "dest_group_owner_account": "", - "direction": "ingress", - "ip_protocol": "TCP", - "nic_type": "internet", - "policy": "Accept", - "port_range": "80/86", - "priority": 1, - "source_cidr_ip": "192.168.0.54/32", - "source_group_id": "", - "source_group_name": "", - "source_group_owner_account": "" - }, - { - "create_time": "2017-06-19T02:43:30Z", - "description": "", - "dest_cidr_ip": "47.89.23.33/32", - "dest_group_id": "", - "dest_group_name": "", - "dest_group_owner_account": "", - "direction": "egress", - "ip_protocol": "TCP", - "nic_type": "internet", - "policy": "Accept", - "port_range": "8080/8085", - "priority": 1, - "source_cidr_ip": "", - "source_group_id": "", - "source_group_name": "", - "source_group_owner_account": "" - } - ], - "tags": {}, - "vpc_id": "" - } -vpc_id: - description: ID of the VPC to which the security group belongs - returned: when present - type: string - sample: "vpc-snif3g3iv" -''' - -import time -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect - - -try: - from footmark.exception import ECSResponseError - - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def authorize_security_group(module, ecs, group_id, inbound_rules, outbound_rules): - """ - authorize security group in ecs - :param module: Ansible module object - :param ecs: authenticated ecs connection object - :param group_id: Security Group Id for authorization - :param inbound_rules: Inbound rules for authorization - :param outbound_rules: Outbound rules for authorization - :param add_to_fail_result: message to add to failed message at the beginning, if two tasks are performed - :return: Returns changed state, security group id and custom message. - """ - - try: - changed = False - inbound_failed_rules, outbound_failed_rules, result = ecs.authorize_security_group( - group_id, inbound_rules, outbound_rules) - - if 'error' in (''.join(str(result))).lower(): - module.fail_json(changed=changed, msg="Authorizing SecurityGroup is failed, error: %s ; group_id: %s ; " - "failed inbound rules: %s ; failed outbound rules: %s." - % (str(result), group_id, inbound_failed_rules, outbound_failed_rules)) - changed = True - - except ECSResponseError as e: - module.fail_json(msg='Unable to authorize security group, error: {0}'.format(e)) - - return changed - - -def validate_format_sg_rules(module, inbound_rules=None, outbound_rules=None): - """ - Validate and format security group for inbound and outbound rules - :param module: Ansible module object - :param inbound_rules: Inbound rules for authorization to validate and format - :param outbound_rules: Outbound rules for authorization to validate and format - :return: - """ - # aliases for rule - ip_protocol_aliases = ('ip_protocol', 'proto') - inbound_cidr_ip_aliases = ('source_cidr_ip', 'cidr_ip') - outbound_cidr_ip_aliases = ('dest_cidr_ip', 'cidr_ip') - inbound_group_id_aliases = ('source_group_id', 'group_id') - outbound_group_id_aliases = ('dest_group_id', 'group_id') - inbound_group_owner_aliases = ('source_group_owner_id', 'group_owner_id') - outbound_group_owner_aliases = ('dest_group_owner_id', 'group_owner_id') - - cidr_ip_aliases = { - "inbound": inbound_cidr_ip_aliases, - "outbound": outbound_cidr_ip_aliases, - } - - group_id_aliases = { - "inbound": inbound_group_id_aliases, - "outbound": outbound_group_id_aliases, - } - - group_owner_aliases = { - "inbound": inbound_group_owner_aliases, - "outbound": outbound_group_owner_aliases, - } - - COMMON_VALID_PARAMS = ('proto', 'ip_protocol', 'cidr_ip', 'group_id', 'group_owner_id', - 'nic_type', 'policy', 'priority', 'port_range') - INBOUND_VALID_PARAMS = ('source_cidr_ip', 'source_group_id', 'source_group_owner_id') - OUTBOUND_VALID_PARAMS = ('dest_cidr_ip', 'dest_group_id', 'dest_group_owner_id') - - rule_types = [] - - rule_choice = { - "inbound": inbound_rules, - "outbound": outbound_rules, - } - valid_params = { - "inbound": INBOUND_VALID_PARAMS, - "outbound": OUTBOUND_VALID_PARAMS, - } - - if inbound_rules: - rule_types.append('inbound') - - if outbound_rules: - rule_types.append('outbound') - - for rule_type in rule_types: - - rules = rule_choice.get(rule_type) - total_rules = 0 - if rules: - total_rules = len(rules) - - if total_rules != 0: - - for rule in rules: - - if not isinstance(rule, dict): - module.fail_json(msg='Invalid rule parameter type [%s].' % type(rule)) - - for k in rule: - if k not in COMMON_VALID_PARAMS and k not in valid_params.get(rule_type): - module.fail_json(msg='Invalid rule parameter \'{}\''.format(k)) - - ip_protocol = get_alias_value(rule, ip_protocol_aliases) - if ip_protocol is None: - module.fail_json(msg="Ip Protocol required for rule authorization") - - port_range = get_alias_value(rule, ['port_range']) - if port_range is None: - module.fail_json(msg="Port range is required for rule authorization") - - # verifying whether group_id is provided and cidr_ip is not, so nic_type should be set to intranet - cidr_ip = get_alias_value(rule, cidr_ip_aliases.get(rule_type)) - if cidr_ip is None: - if get_alias_value(rule, group_id_aliases.get(rule_type)) is not None: - if 'nic_type' in rule: - if not rule['nic_type'] == "intranet": - module.fail_json(msg="In mutual security group authorization (namely, " - "GroupId is specified, while CidrIp is not specified), " - "you must specify the nic_type as intranet") - else: - module.fail_json(msg="In mutual security group authorization (namely, " - "GroupId is specified, while CidrIp is not specified), " - "you must specify the nic_type as intranet") - - # format rules to return for authorization - formatted_rule = {} - - formatted_rule['ip_protocol'] = ip_protocol - formatted_rule['port_range'] = port_range - - if cidr_ip: - formatted_rule['cidr_ip'] = cidr_ip - - group_id = get_alias_value(rule, group_id_aliases.get(rule_type)) - if group_id: - formatted_rule['group_id'] = group_id - - group_owner_id = get_alias_value(rule, group_owner_aliases.get(rule_type)) - if group_owner_id: - formatted_rule['group_owner_id'] = group_owner_id - - if 'nic_type' in rule: - if rule['nic_type']: - formatted_rule['nic_type'] = rule['nic_type'] - - if 'policy' in rule: - if rule['policy']: - formatted_rule['policy'] = rule['policy'] - - if 'priority' in rule: - if rule['priority']: - formatted_rule['priority'] = rule['priority'] - - rule.clear() - rule.update(formatted_rule) - - -def get_alias_value(dictionary, aliases): - """ - Get alias or key value from a dictionary - :param dictionary: a dictionary to check in for keys/aliases - :param aliases: list of aliases to find in dictionary to retrieve value - :return: returns value of found alias else None - """ - - if (dictionary and aliases) is not None: - for alias in aliases: - if alias in dictionary: - return dictionary[alias] - return None - else: - return None - - -def get_group_basic(group): - """ - Parse security group basic information. - returns it as a dictionary - """ - return {'id': group.id, 'name': group.name, 'vpc_id': group.vpc_id} - - -def get_group_detail(group): - """ - Parse security group detail information. - returns it as a dictionary - """ - return {'id': group.id, 'name': group.name, 'description': group.description, 'region_id': group.region_id, - 'tags': group.tags, 'vpc_id': group.vpc_id, 'rules': group.rules} - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - state=dict(default='present', type='str', choices=['present', 'absent']), - group_name=dict(type='str', required=False, aliases=['name']), - description=dict(type='str', required=False), - vpc_id=dict(type='str'), - group_tags=dict(type='list', aliases=['tags']), - rules=dict(type='list'), - rules_egress=dict(type='list'), - group_id=dict(type='str') - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module alicloud_security_group.') - - ecs = ecs_connect(module) - - state = module.params['state'] - group_name = module.params['group_name'] - description = module.params['description'] - vpc_id = module.params['vpc_id'] - group_id = module.params['group_id'] - group_tags = module.params['group_tags'] - - changed = False - group = None - - try: - if group_id: - security_groups = ecs.get_all_security_groups(group_ids=[group_id], vpc_id=vpc_id, name=group_name) - else: - security_groups = ecs.get_all_security_groups(vpc_id=vpc_id, name=group_name) - except ECSResponseError as e: - module.fail_json(msg='Error in get_all_security_groups: %s' % str(e)) - - group_ids = [] - if security_groups and len(security_groups) > 0: - if group_id or len(security_groups) == 1: - group = security_groups[0] - else: - for cur in security_groups: - group_ids.append(cur.id) - module.fail_json(msg="There are several security group in our record based on name {0} or vpc {1}: {2}. " - "Please specified one using 'id' and try again.".format(group_name, vpc_id, group_ids)) - - if state == 'absent': - if not group: - module.fail_json(changed=changed, msg="Please specify a security group by using 'group_id' or 'group_name' " - "and 'vpc_id' before deleting a security group.") - try: - module.exit_json(changed=group.delete()) - except ECSResponseError as e: - module.fail_json(msg="Deleting security group {0} is failed. Error: {1}".format(group.id, e)) - - if not group: - try: - client_token = "Ansible-Alicloud-%s-%s" % (hash(str(module.params)), str(time.time())) - group = ecs.create_security_group(group_name=group_name, description=description, vpc_id=vpc_id, - group_tags=group_tags, client_token=client_token) - changed = True - - except ECSResponseError as e: - module.fail_json(changed=changed, msg='Creating a security group is failed. Error: {0}'.format(e)) - - # validating rules if provided - total_rules_count = 0 - inbound_rules = module.params['rules'] - if inbound_rules: - total_rules_count = len(inbound_rules) - - outbound_rules = module.params['rules_egress'] - if outbound_rules: - total_rules_count += len(outbound_rules) - - if total_rules_count > 100: - module.fail_json(msg='more than 100 rules for authorization are not allowed') - - validate_format_sg_rules(module, inbound_rules, outbound_rules) - - if inbound_rules or outbound_rules: - changed = authorize_security_group(module, ecs, group_id=group.id, inbound_rules=inbound_rules, outbound_rules=outbound_rules) - - module.exit_json(changed=changed, group_id=group.id, group=get_group_detail(group), vpc_id=group.vpc_id) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_slb_lb.py b/lib/ansible/modules/cloud/alicloud/_alicloud_slb_lb.py deleted file mode 100644 index 7a0881e0..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_slb_lb.py +++ /dev/null @@ -1,333 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: alicloud_slb_lb -version_added: "1.0.9" -short_description: Create, Delete, Enable or Disable Server Load Balancer in ECS. -description: - - Create, Delete, Enable or Disable Server Load Balancer in ECS. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_slb_lb) instead. -options: - state: - description: - - The state of the instance after operating. - default: 'present' - choices: [ 'present', 'absent', 'running', 'stopped'] - load_balancer_name: - description: - - The name of the server load balancer, which is a string of 1 to 80 characters. - It can contain numerals, "_", "/", "." or "-". - aliases: [ 'name' ] - load_balancer_id: - description: - - This parameter is required when user wants to perform edit operation in Load Balancer - aliases: ['id'] - load_balancer_status: - description: - - (deprecated) The field has been deprecated from ansible-alicloud v1.1.3. - address_type: - description: - - (deprecated) The field has been deprecated from ansible-alicloud v1.1.3 and 'is_internet' will replace. - is_internet: - description: - - Load balancer network type whether is internet. - type: bool - default: Ture - vswitch_id: - description: - - The vswitch id of the VPC instance. - aliases: ['subnet_id'] - internet_charge_type: - description: - - The charge type of internet. It will be ignored when C(is_internet=False) - default: 'paybytraffic' - choices: ['paybybandwidth', 'paybytraffic'] - master_zone_id: - description: - - The main usable area ID of the created Load Balancer can be found by the DescribeZone interface - slave_zone_id: - description: - - The ID of the standby zone of the created Load Balancer can be found on the DescribeZone interface - bandwidth: - description: - - Bandwidth peak of the public network instance charged per fixed bandwidth. It will be ignored when C(internet_charge_type=paybytraffic) - default: 1 - choices: [ 1-1000 Mbps ] -requirements: - - "python >= 2.6" - - "footmark >= 1.1.18" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" - - "Liu Qiang" -""" - -EXAMPLES = ''' -# Basic provisioning example to create Load Balancer -- name: create server load balancer - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_access_key: - alicloud_secret_key: - load_balancer_name: demo_slb - internet_charge_type: paybytraffic - state: present - tasks: - - name: create server load balancer - alicloud_slb_lb: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_name: '{{ load_balancer_name }}' - address_type: '{{ address_type }}' - internet_charge_type: '{{ internet_charge_type }}' - state: '{{ state }}' - register: result - - debug: var=result - -# Basic provisioning example to Modify SLB Internet Specification -- name: modify server load balancer internet specification - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_access_key: - alicloud_secret_key: - load_balancer_id: - internet_charge_type: paybytraffic - bandwidth: 5 - tasks: - - name: modify server load balancer internet specification - alicloud_slb_lb: - alicloud_region: '{{ alicloud_region }}' - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - load_balancer_id: '{{ load_balancer_id }}' - internet_charge_type: '{{ internet_charge_type }}' - bandwidth: '{{ bandwidth }}' - register: result - - debug: var=result - -# Basic provisioning example to Delete Server Load Balancer -- name: delete server load balancer - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_access_key: - alicloud_secret_key: - load_balancer_id: - state : absent - tasks: - - name: delete server load balancer - alicloud_slb_lb: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - state: '{{ state }}' - register: result - - debug: var=result - -# Basic provisioning example to set Server Load Balancer Name -- name: set server load balancer name - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_access_key: - alicloud_secret_key: - load_balancer_id: - load_balancer_name: slb_new_name - state : present - tasks: - - name: set server load balancer name - alicloud_slb_lb: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - load_balancer_name: '{{ load_balancer_name }}' - state: '{{ state }}' - register: result - - debug: var=result -''' -RETURN = ''' -load_balancer: - description: - - Describe the current info of load_balancer after user operate a load_balancer - returned: on present - type: string - sample: { - "address": "101.201.177.136", - "bandwidth": null, - "internet_charge_type": "4", - "id": "lb-2zekcf2uvij5yw3a7t1c3", - "name": "test_change_name", - "status": "active", - "network_type": "classic" - } -load_balancer_id: - description: - - Unique identification of load balancing instance - returned: on present or absent - type: string - sample: "lb-2zekcf2uvij5yw3a7t1c3" -''' - -import time -import sys -from ast import literal_eval -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, slb_connect - - -HAS_ECS = False -HAS_FOOTMARK = False - -try: - from footmark.exception import SLBResponseError - - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(lb_obj): - """ - get info from lb object - :param lb_obj: lb obj - :return: info of lb - """ - return dict(id=lb_obj.load_balancer_id, - name=lb_obj.load_balancer_name, - address=lb_obj.address, - internet_charge_type=lb_obj.internet_charge_type, - bandwidth=lb_obj.bandwidth, - load_balancer_status=lb_obj.load_balancer_status, - network_type=lb_obj.network_type) - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - internet_charge_type=dict(type='str', required=False, choices=['paybybandwidth', 'paybytraffic'], default='paybytraffic'), - state=dict(type='str', required=True, choices=['present', 'absent', 'running', 'stopped']), - load_balancer_name=dict(type='str', required=False, aliases=['name']), - load_balancer_id=dict(type='str', required=False, aliases=['id']), - is_internet=dict(type='bool', required=False, default=True), - bandwidth=dict(type='int', required=False, default=1), - vswitch_id=dict(type='str', required=False, aliases=['subnet_id']), - master_zone_id=dict(type='str', required=False), - slave_zone_id=dict(type='str', required=False) - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module alicloud_slb_lb.') - - slb = slb_connect(module) - state = module.params['state'] - load_balancer_id = module.params['load_balancer_id'] - load_balancer_name = module.params['load_balancer_name'] - is_internet = module.params['is_internet'] - vswitch_id = module.params['vswitch_id'] - master_zone_id = module.params['master_zone_id'] - slave_zone_id = module.params['slave_zone_id'] - internet_charge_type = module.params['internet_charge_type'] - bandwidth = module.params['bandwidth'] - - changed = False - cur_slb = None - - if load_balancer_id and load_balancer_name: - name_test = "" - else: - name_test = load_balancer_name - res_objs = slb.describe_load_balancers(load_balancer_id=load_balancer_id, load_balancer_name=name_test) - if len(res_objs) == 1: - cur_slb = slb.describe_load_balancer_attribute(res_objs[0].id) - - if state == "present": - if cur_slb: - if load_balancer_name != cur_slb.name: - changed = cur_slb.modify_name(load_balancer_name) - if changed: - cur_slb.load_balancer_name = load_balancer_name - - if internet_charge_type != cur_slb.internet_charge_type or \ - (cur_slb.internet_charge_type == "paybybandwidth" and bandwidth != cur_slb.bandwidth): - print (cur_slb.__dict__) - print (cur_slb.internet_charge_type, cur_slb.bandwidth) - changed = cur_slb.modify_spec(internet_charge_type=internet_charge_type, bandwidth=bandwidth) - if changed: - cur_slb.internet_charge_type = internet_charge_type - cur_slb.bandwidth = bandwidth - else: - client_token = "Ansible-Alicloud-%s-%s" % (hash(str(module.params)), str(time.time())) - address_type = "internet" - if not is_internet: - address_type = "intranet" - cur_slb = slb.create_load_balancer(load_balancer_name=load_balancer_name, - address_type=address_type, vswitch_id=vswitch_id, - internet_charge_type=internet_charge_type, - master_zone_id=master_zone_id, slave_zone_id=slave_zone_id, - bandwidth=bandwidth, client_token=client_token) - changed = True - module.exit_json(changed=changed, load_balancer=get_info(cur_slb), load_balancer_id=cur_slb.id) - - if not cur_slb: - module.fail_json(msg="The specified load balancer is not exist. Please check your load_balancer_id or load_balancer_name and try again.") - - if state == "absent": - changed = cur_slb.delete() - module.exit_json(changed=changed, load_balancer_id=cur_slb.load_balancer_id) - if state == "running": - if cur_slb.status != "active": - changed = cur_slb.set_status("active") - if changed: - cur_slb.load_balancer_status = "active" - module.exit_json(changed=changed, load_balancer=get_info(cur_slb), load_balancer_id=cur_slb.load_balancer_id) - - if state == "stopped": - if cur_slb.status != "inactive": - changed = cur_slb.set_status("inactive") - if changed: - cur_slb.load_balancer_status = "inactive" - module.exit_json(changed=changed, load_balancer=get_info(cur_slb), load_balancer_id=cur_slb.load_balancer_id) - - -if __name__ == "__main__": - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_slb_listener.py b/lib/ansible/modules/cloud/alicloud/_alicloud_slb_listener.py deleted file mode 100644 index c31f98af..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_slb_listener.py +++ /dev/null @@ -1,478 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: alicloud_slb_listener -version_added: "1.0.9" -short_description: Create, Delete, Start or Stop Server Load Balancer Listener in ECS -description: - - Create, Delete, Start or Stop Server Load Balancer Listener in ECS -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_slb_listener) instead. -options: - state: - description: - - The state of the load balancer listener after operating. - required: true - choices: [ 'present', 'absent', 'running', 'stopped'] - load_balancer_id: - description: - - The unique ID of an Server Load Balancer instance - required: true - listener_type: - description: - - (deprecated) This field has been deprecated from ansible-alicloud (v1.1.3), and 'protocol' will replace it. - protocol: - description: - - The protocol which listener used. It is requried when C(state=present). - required: false - choices: [ 'http', 'https', 'tcp', 'udp'] - listener_port: - description: - - Port used by the Server Load Balancer instance frontend - required: true - choices: [1~65535] - aliases: ['frontend_port'] - bandwidth: - description: - - Bandwidth peak of Listener. It is required when C(present) - choices: [-1/1-1000] - required: false - backend_server_port: - description: - - Port used by the Server Load Balancer instance backend port - choices: [1~65535] - aliases: ['backend_port'] - scheduler: - description: - - Scheduling algorithm. - default: 'wrr' - choices: ['wlc', 'wrr'] - sticky_session: - description: - - Whether to enable session persistence. - choices: ['on', 'off'] - defalut: 'off' - sticky_session_type: - description: - - Mode for handling the cookie. Required when C(sticky_session='on'). - choices: ['server', 'insert'] - cookie_timeout: - description: - - Cookie timeout, Required when C(sticky_session='on', sticky_session_type='insert') - choices: [ 1~86400] - cookie: - description: - - The cookie configured on the server. Required when C(sticky_session='on', sticky_session_type='server') - persistence_timeout: - description: - - Timeout of connection persistence. - default: 0 - choices: [0~3600] - health_check: - description: - - Whether to enable health check. TCP and UDP listener's HealthCheck is always on, so it will be ignore when launching TCP or UDP listener. - choices: ['on', 'off'] - defalut: on - health_check_type: - description: - - Type of health check. TCP supports TCP and HTTP health check mode, you can select the particular mode depending on your application. - default: 'tcp' - choices: ['tcp', 'http'] - health_check_domain: - description: - - Domain name used for health check. - When it is not set or empty, Server Load Balancer uses the private network IP address of each backend server as Domain used for health check. - health_check_uri: - description: - - URI used for health check. Required when C(health_check='on'). - default: "/" - health_check_connect_port: - description: - - Port used for health check. Required when C(health_check='on'). Default to C(backend_server_port). - choices: [1~65535] - healthy_threshold: - description: - - Threshold determining the result of the health check is success. - Namely, after how many successive successful health checks, - the health check result of the backend server is changed from fail to success. Required when C(health_check='on'). - choices: [1-10] - default: 3 - unhealthy_threshold: - description: - - Threshold determining the result of the health check is fail. - Namely, after how many successive failed health checks, - the health check result of the backend server is changed from success to fail. Required when C(health_check='on'). - choices: [1-10] - default: 3 - health_check_timeout: - description: - - Maximum timeout of each health check response. Required when C(health_check='on'). - choices: [1-300] - default: 5 - health_check_interval: - description: - - Time interval of health checks. Required when C(health_check='on'). - choices: [1-50] - default: 2 - health_check_http_code: - description: - - Regular health check HTTP status code. Multiple codes are segmented by ",". Required when C(health_check='on'). - default: http_2xx - choices: ['http_2xx','http_3xx', 'http_4xx', 'http_5xx'] - vserver_group_id: - description: - - Virtual server group ID, when the VserverGroup is on, the incoming VServerGroupId value takes effect. - server_certificate_id: - description: - - Server certificate ID - -requirements: - - "python >= 2.6" - - "footmark >= 1.1.18" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" -""" - -EXAMPLES = """ -# Basic provisioning example to create Load Balancer Listener -- name: create server load balancer http listener - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_access_key: - alicloud_secret_key: - load_balancer_id: - listener_port: 80 - backend_server_port: 80 - state: present - tasks: - - name: create server load balancer listener - alicloud_slb_listener: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - listener_port: '{{ listener_port }}' - backend_server_port: '{{ backend_server_port }}' - bandwidth: 1 - sticky_session: off - health_check: off - protocol: http - state: '{{ state }}' - register: result - - debug: var=result - -# Basic provisioning example to stop Load Balancer Listener -- name: stop server load balancer listener - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_access_key: - alicloud_secret_key: - load_balancer_id: - listener_port: 80 - state: stopped - tasks: - - name: stop server load balancer listener - alicloud_slb_listener: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - protocol: http - listener_port: '{{ listener_port }}' - state: '{{ state }}' - register: result - - debug: var=result - -# Basic provisioning example to start Load Balancer Listener -- name: start server load balancer listener - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_access_key: - alicloud_secret_key: - load_balancer_id: - listener_port: 80 - state: running - tasks: - - name: start server load balancer listener - alicloud_slb_listener: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - protocol: http - listener_port: '{{ listener_port }}' - state: '{{ state }}' - register: result - - debug: var=result - -# Basic provisioning example to set listener attribute -- name: set listener attribute - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_access_key: - alicloud_secret_key: - load_balancer_id: - listener_port: 80 - state: present - tasks: - - name: set listener attribute - alicloud_slb_listener: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - protocol: http - load_balancer_id: '{{ load_balancer_id }}' - listener_port: '{{ listener_port }}' - bandwidth: 4 - scheduler: wlc - sticky_session: off - health_check: off - state: '{{ state }}' - register: result - - debug: var=result - -# Basic provisioning example to delete listener -- name: delete listener - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_access_key: - alicloud_secret_key: - load_balancer_id: - listener_port: 80 - state: absent - tasks: - - name: delete listener - alicloud_slb_listener: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - listener_port: '{{ listener_port }}' - state: '{{ state }}' - register: result - - debug: var=result -""" -RETURN = ''' -listener: - description: - - The info of load balancer listener - returned: when success - type: dict - sample: { - "backend_server_port": 80, - "bandwidth": 4, - "listener_port": 80, - "schedule": null, - "server_certificate_id": null, - "status": "running", - "sticky_session": "off", - } -''' - -import time -import sys -from ast import literal_eval -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, slb_connect - - -HAS_ECS = False -HAS_FOOTMARK = False - -try: - from footmark.exception import SLBResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(obj): - """ - get info from lb object - :param lb_ls_obj: lb obj - :return: info of lb - """ - result = dict(listener_port=obj.listener_port, - backend_server_port=obj.backend_server_port, - bandwidth=obj.bandwidth, - status=obj.status, - schedule=obj.schedule) - - if hasattr(obj, 'server_certificate_id'): - result['server_certificate_id'] = obj.server_certificate_id - if hasattr(obj, 'sticky_session'): - result['sticky_session'] = obj.sticky_session - if hasattr(obj, 'persistence_timeout'): - result['persistence_timeout'] = obj.persistence_timeout - return result - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - listener_port=dict(type='int', required=True, choices=[i for i in range(1, 65536)], aliases=['frontend_port']), - state=dict(type='str', required=True, choices=['present', 'absent', 'stopped', 'running']), - load_balancer_id=dict(type='str', required=True, aliases=['id']), - backend_server_port=dict(type='int', choices=[i for i in range(1, 65536)], aliases=['backend_port']), - bandwidth=dict(type='int', choices=([i for i in range(1, 1001)]).append(-1)), - sticky_session=dict(type='str', choices=['on', 'off']), - protocol=dict(type='str', choices=['http', 'https', 'tcp', 'udp']), - health_check=dict(type='str', default= 'on', choices=['on', 'off']), - scheduler=dict(type='str', default='wrr', choices=['wrr', 'wlc']), - sticky_session_type=dict(type='str', choices=['insert', 'server']), - cookie_timeout=dict(type='str', choices=[i for i in range(1, 86401)]), - cookie=dict(type='str'), - health_check_domain=dict(type='str'), - health_check_uri=dict(type='str', default='/'), - health_check_connect_port=dict(type='int', choices=([i for i in range(1, 65536)]).append(-520)), - healthy_threshold=dict(type='int', default=3, choices=[i for i in range(1, 11)]), - unhealthy_threshold=dict(type='int', default=3, choices=[i for i in range(1, 11)]), - health_check_timeout=dict(type='int', default=5, choices=[i for i in range(1, 51)]), - health_check_interval=dict(type='int', default=2, choices=[i for i in range(1, 6)]), - health_check_http_code=dict(type='str', default='http_2xx'), - vserver_group_id=dict(type='str'), - persistence_timeout=dict(type='int', default=0, choices=[i for i in range(0, 3601)]), - server_certificate_id=dict(type='str'), - health_check_type=dict(type='str', default='tcp', choice=['tcp', 'http']), - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module alicloud_slb_listener.') - - slb = slb_connect(module) - state = module.params['state'] - load_balancer_id = module.params['load_balancer_id'] - listener_port = module.params['listener_port'] - backend_server_port = module.params['backend_server_port'] - bandwidth = module.params['bandwidth'] - sticky_session = module.params['sticky_session'] - protocol = module.params['protocol'] - health_check = module.params['health_check'] - scheduler = module.params['scheduler'] - sticky_session_type = module.params['sticky_session_type'] - cookie_timeout = module.params['cookie_timeout'] - cookie = module.params['cookie'] - health_check_domain = module.params['health_check_domain'] - health_check_uri = module.params['health_check_uri'] - health_check_connect_port = module.params['health_check_connect_port'] - healthy_threshold = module.params['healthy_threshold'] - unhealthy_threshold = module.params['unhealthy_threshold'] - health_check_timeout = module.params['health_check_timeout'] - health_check_interval = module.params['health_check_interval'] - health_check_http_code = module.params['health_check_http_code'] - vserver_group_id = module.params['vserver_group_id'] - server_certificate_id = module.params['server_certificate_id'] - persistence_timeout = module.params['persistence_timeout'] - health_check_type = module.params['health_check_type'] - - current_listener = slb.describe_load_balancer_listener_attribute(load_balancer_id, listener_port, protocol) - changed = False - if state == "present": - if current_listener: - changed = current_listener.set_attribute(load_balancer_id=load_balancer_id, - bandwidth=bandwidth, - sticky_session=sticky_session, - protocol=protocol, - health_check=health_check, - scheduler=scheduler, - sticky_session_type=sticky_session_type, - cookie_timeout=cookie_timeout, - cookie=cookie, - health_check_domain=health_check_domain, - health_check_uri=health_check_uri, - health_check_connect_port=health_check_connect_port, - healthy_threshold=healthy_threshold, - unhealthy_threshold=unhealthy_threshold, - health_check_timeout=health_check_timeout, - health_check_interval=health_check_interval, - health_check_http_code=health_check_http_code, - vserver_group_id=vserver_group_id, - server_certificate_id=server_certificate_id, - persistence_timeout=persistence_timeout, - health_check_type=health_check_type) - module.exit_json(changed=changed, listener=get_info(current_listener.describe_attribute(load_balancer_id, protocol))) - else: - changed = slb.create_load_balancer_listener(load_balancer_id=load_balancer_id, - listener_port=listener_port, - backend_server_port=backend_server_port, - bandwidth=bandwidth, - sticky_session=sticky_session, - protocol=protocol, - health_check=health_check, - scheduler=scheduler, - sticky_session_type=sticky_session_type, - cookie_timeout=cookie_timeout, - cookie=cookie, - health_check_domain=health_check_domain, - health_check_uri=health_check_uri, - health_check_connect_port=health_check_connect_port, - healthy_threshold=healthy_threshold, - unhealthy_threshold=unhealthy_threshold, - health_check_timeout=health_check_timeout, - health_check_interval=health_check_interval, - health_check_http_code=health_check_http_code, - vserver_group_id=vserver_group_id, - server_certificate_id=server_certificate_id, - persistence_timeout=persistence_timeout) - new_current_listener = slb.describe_load_balancer_listener_attribute(load_balancer_id, listener_port, protocol) - module.exit_json(changed=changed, listener=get_info(new_current_listener)) - if not current_listener: - module.fail_json(msg="The specified load balancer listener is not exist. Please check your load_balancer_id or listener_port and try again.") - if state == "absent": - changed = current_listener.delete(load_balancer_id) - module.exit_json(changed=changed, listener=get_info(current_listener)) - if state == "running": - if current_listener.status == "stopped": - # start - changed = current_listener.start(load_balancer_id) - module.exit_json(changed=changed, listener=get_info(current_listener.describe_attribute(load_balancer_id, protocol))) - if state == "stopped": - if current_listener.status == "running": - # stop - changed = current_listener.stop(load_balancer_id) - module.exit_json(changed=changed, listener=get_info(current_listener.describe_attribute(load_balancer_id, protocol))) - - -if __name__ == "__main__": - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_slb_server.py b/lib/ansible/modules/cloud/alicloud/_alicloud_slb_server.py deleted file mode 100644 index 7d0e11e7..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_slb_server.py +++ /dev/null @@ -1,440 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: alicloud_slb_server -version_added: "1.0.9" -short_description: Add or remove a list of backend servers to/from a specified SLB -description: - - Returns information about the backend servers. Will be marked changed when called only if state is changed. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_slb_server) instead. -options: - state: - description: - - Add or remove backend server to/from a specified slb - default: 'present' - choices: ['present', 'absent'] - load_balancer_id: - description: - - The unique ID of a Server Load Balancer instance - required: true - aliases: [ 'lb_id'] - backend_servers: - description: - - List of hash/dictionary of backend servers to add or set in when C(state=present) - - List IDs of backend servers which in the load balancer when C(state=absent) - required: true - aliases: [ 'servers'] - suboptions: - server_id: - description: - - The ID of ecs instance which is added into load balancer. - required: true - weight: - description: - - The weight of backend server in the load balancer. - choices: [0~100] - default: 100 -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" -""" - -EXAMPLES = ''' -# Provisioning new add or remove Backend Server from SLB -# Basic example to add backend server to load balancer instance -- name: add backend server - hosts: localhost - connection: local - vars: - load_balancer_id: lb-abcd1234 - tasks: - - name: add backend server - alicloud_slb_server: - load_balancer_id: '{{ load_balancer_id }}' - backend_servers: - - server_id: i-abcd1234 - weight: 70 - - server_id: i-abce1245 - -#Basic example to set backend server of load balancer instance -- name: set backend server - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - tasks: - - name: set backend server - alicloud_slb_server: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - load_balancer_id: lb-abcd1234 - backend_servers: - - server_id: i-abcd1234 - weight: 50 - - server_id: i-abcd1234 - weight: 80 - -#Basic example to remove backend servers from load balancer instance -- name: remove backend servers - hosts: localhost - connection: local - tasks: - - name: remove backend servers - alicloud_slb_server: - load_balancer_id: lb-abcd1234 - state: absent - backend_servers: - - i-abcd1234 - - i-abcd1234 - -''' -RETURN = ''' -load_balancer_id: - description: ID of the load balancer. - returned: when success - type: string - sample: "lb-2zeyfm5a14c9ffxvxmvco" -"backend_servers": - description: Details about the backened-servers that were added. - returned: when success - type: list - sample: [ - { - "health_status": "abnormal", - "id": "i-2zeau2evvbnwufq0fa7q" - }, - { - "health_status": "abnormal", - "id": "i-2zehasnejqr6g6agys5a" - } - ] -''' - -import time -import sys -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, slb_connect - -try: - from footmark.exception import SLBResponseError - - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_backen_server_weight(server): - """ - Retrieves instance information from an instance - ID and returns it as a dictionary - """ - return {'id': server.id, 'weight': server.weight} - - -def get_backen_server_status(server): - """ - Retrieves instance information from an instance - ID and returns it as a dictionary - """ - return {'id': server.id, 'health_status': server.status} - - -def add_set_backend_servers(module, slb, load_balancer_id, backend_servers): - """ - Add and/or Set backend servers to an slb - - :param module: Ansible module object - :param slb: authenticated slb connection object - :param load_balancer_id: load balancer id to add/set backend servers to - :param backend_servers: backend severs information to add/set - :return: returns changed state, current added backend servers and custom message. - """ - - changed = False - server_id_param = 'server_id' - backend_servers_to_set = [] - backend_servers_to_add = [] - result = [] - current_backend_servers = [] - changed_after_add = False - changed_after_set = False - - try: - - load_balancer_info = slb.describe_load_balancer_attribute(load_balancer_id) - - # Verifying if server load balancer Object is present - if load_balancer_info: - existing_backend_servers = str(load_balancer_info.backend_servers['backend_server']) - - # Segregating existing backend servers from new backend servers from the provided backend servers - for backend_server in backend_servers: - - backend_server_string = backend_server[server_id_param] + '\'' - if backend_server_string in existing_backend_servers: - backend_servers_to_set.append(backend_server) - else: - backend_servers_to_add.append(backend_server) - - # Adding new backend servers if provided - if len(backend_servers_to_add) > 0: - current_backend_servers.extend(slb.add_backend_servers(load_balancer_id=load_balancer_id, backend_servers=backend_servers_to_add)) - changed = True - # Setting exisiting backend servers if provided - if len(backend_servers_to_set) > 0: - backen_servers = slb.set_backend_servers(load_balancer_id=load_balancer_id, backend_servers=backend_servers_to_set) - changed = True - # If backend server result after set action is available then clearing actual list - # and adding new result to it. - if len(backen_servers) > 0: - # Below operation clears list using slice operation - current_backend_servers[:] = [] - current_backend_servers.extend(backen_servers) - - if changed_after_add or changed_after_set: - changed = True - - else: - module.fail_json(msg="Could not find provided load balancer instance") - - except SLBResponseError as ex: - module.fail_json(msg='Unable to add backend servers, error: {0}'.format(ex)) - - return changed, current_backend_servers - - -def remove_backend_servers(module, slb, load_balancer_id, backend_servers): - """ - Remove backend servers from an slb - - :param module: Ansible module object - :param slb: authenticated slb connection object - :param load_balancer_id: load balancer id to remove backend servers from - :param backend_servers: list of backend server ids to remove from slb - :return: returns changed state, current added backend servers and custom message. - """ - - changed = False - - try: - backend_servers = slb.remove_backend_servers(load_balancer_id=load_balancer_id, backend_server_ids=backend_servers) - changed = True - - except SLBResponseError as ex: - module.fail_json(msg='Unable to remove backend servers, error: {0}'.format(ex)) - - return changed, backend_servers - - -def describe_backend_servers_health_status(module, slb, load_balancer_id=None, listener_ports=None): - """ - Describe health status of added backend servers of an slb - - :param module: Ansible module object - :param slb: authenticated slb connection object - :param load_balancer_id: load balancer id to remove backend servers from - :param listener_ports: list of ports to for which backend server health status is required - :return: returns backend servers health status and custom message - """ - - backend_servers_health_status = [] - try: - if listener_ports: - for port in listener_ports: - - backend_server = slb.describe_backend_servers_health_status(load_balancer_id=load_balancer_id, port=port) - backend_servers_health_status.extend(backend_server) - else: - backend_servers_health_status = slb.describe_backend_servers_health_status(load_balancer_id=load_balancer_id) - - except SLBResponseError as ex: - module.fail_json(msg='Unable to describe backend servers health status, error: {0}'.format(ex)) - - return backend_servers_health_status - - -def validate_backend_server_info(module, backend_servers, default_weight): - """ - Validate backend server information provided by user for add, set and remove action - - :param module: Ansible module object - :param backend_servers: backend severs information to validate (list of dictionaries or string) - :param default_weight: assigns default weight, if provided, for a backend server to set/add - """ - - server_id_param = 'server_id' - weight_param = 'weight' - VALID_PARAMS = (server_id_param, weight_param) - - for backend_server in backend_servers: - - if isinstance(backend_server, dict) is False: - module.fail_json(msg='Invalid backend_servers parameter type [%s] for state=present.' % type(backend_server)) - - for k in backend_server: - if k not in VALID_PARAMS: - module.fail_json(msg='Invalid backend_server parameter \'{}\''.format(k)) - - server_id = get_sub_value(backend_server, [server_id_param]) - if server_id is None: - module.fail_json(msg="'server_id': required field is set") - - weight = get_sub_value(backend_server, [weight_param]) - - if weight is None: - backend_server[weight_param] = default_weight - else: - # verifying weight parameter for non numeral string and limit validation - try: - w = int(weight) - if w < 0 or w > 100: - module.fail_json(msg="'weight': field value is invalid. Expect to [0-100].") - except Exception as e: - module.fail_json(msg="'weight': field value is invalid. Expect to positive integer [0-100].") - - -def get_sub_value(dictionary, aliases): - """ - - :param dictionary: a dictionary to check in for aliases - :param aliases: list of keys to check in dictionary for value retrieval - :return: returns value if alias found else none - """ - - if (dictionary and aliases) is not None: - for alias in aliases: - if alias in dictionary: - return dictionary[alias] - return None - else: - return None - - -def get_verify_listener_ports(module, listener_ports=None): - """ - Validate and get listener ports - - :param module: Ansible module object - :param listener_ports: list of ports to for which backend server health status is required - :return: formatted listener ports - """ - - if listener_ports: - if len(listener_ports) > 0: - for port in listener_ports: - - try: - port = int(port) - except Exception as ex: - module.fail_json(msg='Invalid port value') - else: - listener_ports = None - - return listener_ports - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - state=dict(choices=['present', 'absent'], default='present'), - backend_servers=dict(required=True, type='list', aliases=['servers']), - load_balancer_id=dict(required=True, aliases=['lb_id']), - )) - - # handling region parameter which is not required by this module - del argument_spec['alicloud_region'] - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg="'footmark' is required for the module alicloud_slb_server. " - "Please install 'footmark' by using 'sudo pip install footmark'.") - - # handling region parameter which is required by common utils file to login but not required by this module - module.params['alicloud_region'] = 'cn-hangzhou' - slb = slb_connect(module) - - state = module.params['state'] - backend_servers = module.params['backend_servers'] - load_balancer_id = module.params['load_balancer_id'] - - if state == 'present': - - if len(backend_servers) > 0: - - validate_backend_server_info(module, backend_servers, 100) - - changed, current_backend_servers = add_set_backend_servers(module, slb, load_balancer_id, backend_servers) - - result_servers = [] - for server in current_backend_servers: - result_servers.append(get_backen_server_weight(server)) - module.exit_json(changed=changed, backend_servers=result_servers, load_balancer_id=load_balancer_id) - else: - module.fail_json(msg='backend servers information is mandatory to state=present') - - if len(backend_servers) > 0: - - if isinstance(backend_servers, list) is False: - module.fail_json(msg='Invalid backend_server parameter type [%s] for state=absent.' % type(backend_servers)) - - changed, backend_servers = remove_backend_servers(module, slb, load_balancer_id, backend_servers) - result_servers = [] - for server in backend_servers: - result_servers.append(get_backen_server_weight(server)) - module.exit_json(changed=changed, backend_servers=result_servers, load_balancer_id=load_balancer_id) - else: - module.fail_json(msg='backend server ID(s) information is mandatory to state=absent') - - # elif state == 'list': - # - # if load_balancer_id: - # - # listener_ports = get_verify_listener_ports(module, listener_ports) - # - # backend_servers = describe_backend_servers_health_status(module, slb, load_balancer_id=load_balancer_id, - # listener_ports=listener_ports) - # - # result_servers = [] - # for server in backend_servers: - # result_servers.append(get_backen_server_status(server)) - # module.exit_json(changed=changed, backend_servers=result_servers, load_balancer_id=load_balancer_id) - # else: - # module.fail_json(msg='load balancer id is mandatory to perform action') - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_slb_vsg.py b/lib/ansible/modules/cloud/alicloud/_alicloud_slb_vsg.py deleted file mode 100644 index 37481982..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_slb_vsg.py +++ /dev/null @@ -1,385 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = ''' ---- -module: alicloud_slb_vsg -version_added: "2.5" -short_description: Create, Delete VServerGroup and Modify its name or backend servers. -description: - - Create, Delete VServerGroup and Modify its name or backend servers. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_slb_vsg) instead. -options: - state: - description: - - The state of the instance after operating. - default: 'present' - choices: [ 'present', 'absent', 'list'] - load_balancer_id: - description: - - The unique ID of an Server Load Balancer instance, It is required when need to create a new vserver group. - vserver_group_name: - description: - - Virtual server group name - aliases: [ 'group_name' ] - backend_servers: - description: - - List of backend servers that need to be added. - suboptions: - instance_id: - description: - - The ID of backend server. - required: true - port: - description: - - Port used to backend server - required: true - choices: [1~65536] - weight: - description: - - The weigth of the backend server - default: 100 - choices: [1~101] - vserver_group_id: - description: - - Virtual server group id. It is required when need to operate an existing vserver group. - aliases: [ 'group_id' ] -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" - - "Liu Qiang" -''' - -EXAMPLES = ''' -# basic provisioning example to create VServer Group in SLB -- name: Create VServer Group in SLB - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: ap-southeast-1 - load_balancer_id: - vserver_group_name: test - backend_servers: - - instance_id: - port: 8080 - weight: 100 - tasks: - - name: Create VServer Group in SLB - alicloud_slb_vsg: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - vserver_group_name: '{{ vserver_group_name }}' - backend_servers: '{{ backend_servers }}' - state: present - register: result - - debug: var=result - -# basic provisioning example to set VServer Group attribute in SLB -- name: set VServer Group attribute in SLB - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: ap-southeast-1 - load_balancer_id: - vserver_group_name: test - backend_servers: - - instance_id: - port: 8080 - weight: 100 - tasks: - - name: Set VServer Group attribute in SLB - alicloud_slb_vsg: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ load_balancer_id }}' - vserver_group_name: '{{ vserver_group_name }}' - backend_servers: '{{ backend_servers }}' - state: present - register: result - - debug: var=result - -# basic provisioning example to add VServer Group Backend Servers in SLB -- name: Add VServer Group Backend Servers in SLB - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: ap-southeast-1 - vserver_group_id: - backend_servers: - - instance_id: - port: 8080 - weight: 100 - tasks: - - name: Add VServer Group Backend Servers in SLB - alicloud_slb_vsg: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - vserver_group_id: '{{ vserver_group_id }}' - backend_servers: '{{ backend_servers }}' - state: present - register: result - - debug: var=result - -# basic provisioning example to remove VServer Group Backend Servers in SLB -- name: remove VServer Group Backend Servers in SLB - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: ap-southeast-1 - vserver_group_id: - backend_servers: - - instance_id: - port: 8080 - tasks: - - name: remove VServer Group Backend Servers in SLB - alicloud_slb_vsg: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - vserver_group_id: '{{ vserver_group_id }}' - backend_servers: '{{ backend_servers }}' - state: absent - register: result - - debug: var=result - -# basic provisioning example to describe VServer Group in SLB -- name: describe VServer Group - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: ap-southeast-1 - vserver_group_id: - tasks: - - name: Describe VServer Group in SLB - alicloud_slb_vsg: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - vserver_group_id: '{{ vserver_group_id }}' - state: list - register: result - - debug: var=result - -# basic provisioning example to delete VServer Group in SLB -- name: Delete VServer Group - hosts: localhost - connection: local - vars: - alicloud_access_key: - alicloud_secret_key: - alicloud_region: ap-southeast-1 - vserver_group_id: - tasks: - - name: Delete VServer Group in SLB - alicloud_slb_vsg: - alicloud_access_key: '{{ alicloud_access_key }}' - alicloud_secret_key: '{{ alicloud_secret_key }}' - alicloud_region: '{{ alicloud_region }}' - vserver_group_id: '{{ vserver_group_id }}' - state: absent - register: result - - debug: var=result -''' - -RETURN = ''' -vserver_group: - description: - - The info of vserver_group - returned: when success - type: dict - sample: { - "backend_servers": { - "backend_server": [ - { - "port": 80, - "server_id": "i-2ze3ajpeq3y80w4lt4jr", - "weight": 100 - } - ] - }, - "vserver_group_id": "rsp-2zejxvoxensk1", - "vserver_group_name": "Group123" - } -''' - -import time -import sys -from ast import literal_eval -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, slb_connect - - -HAS_FOOTMARK = False - -try: - from footmark.exception import SLBResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def get_info(obj): - """ - get info from vsg object - :param obj: vsg obj - :return: res: info of vsg - """ - res = {'vserver_group_id': obj.vserver_group_id} - - if hasattr(obj, 'backend_servers'): - res['backend_servers'] = obj.backend_servers - if hasattr(obj, 'vserver_group_name'): - res['vserver_group_name'] = obj.vserver_group_name - return res - - -def convert_to_utf8(obj): - if sys.version_info.major == 3: - return obj - if isinstance(obj, dict): - res = {} - for key, value in obj.iteritems(): - res = dict(res, **{convert_to_utf8(key): convert_to_utf8(value)}) - return res - elif isinstance(obj, list): - res = [] - for i in obj: - res.append(convert_to_utf8(i)) - return res - elif type(obj) not in [int, float, bool, complex, long]: - return obj.encode('utf-8') - return obj - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - state=dict(type='str', default='present', choices=['present', 'absent', 'list']), - load_balancer_id=dict(type='str'), - vserver_group_name=dict(type='str', aliases=['group_name']), - backend_servers=dict(type='list'), - vserver_group_id=dict(type='str', aliases=['group_id']), - old_backend_servers=dict(type='list'), - new_backend_servers=dict(type='list') - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module alicloud_slb_vsg.') - - slb = slb_connect(module) - state = module.params['state'] - load_balancer_id = module.params['load_balancer_id'] - vserver_group_name = module.params['vserver_group_name'] - backend_servers = module.params['backend_servers'] - vserver_group_id = module.params['vserver_group_id'] - changed = False - current_vserver_group = None - - if vserver_group_id: - try: - current_vserver_group = slb.describe_vserver_group_attribute(vserver_group_id) - except Exception as e: - module.fail_json(msg=str("Unable to describe vserver group attribute, error:{0}".format(e))) - if state == "present": - if current_vserver_group: - set_data = [] - add_data = [] - if backend_servers: - server_info = {} - decode_infos = convert_to_utf8(current_vserver_group.backend_servers) - for info in decode_infos['backend_server']: - server_info[info['port']] = info - for server in backend_servers: - if server['port'] in server_info.keys(): - if server_info[server['port']]['weight'] != server['weight']: - set_data.append(server) - else: - add_data.append(server) - if set_data or vserver_group_name: - try: - current_vserver_group.set_attribute(backend_servers=set_data, vserver_group_name=vserver_group_name) - except Exception as e: - module.fail_json(msg=str("Unable to set vserver group attribute, error:{0}".format(e))) - if add_data: - try: - current_vserver_group.add_backend_servers(backend_servers=add_data) - except Exception as e: - module.fail_json(msg=str("Unable to add vserver group backend server, error:{0}".format(e))) - try: - current_vserver_group = slb.describe_vserver_group_attribute(vserver_group_id) - except Exception as e: - module.fail_json(msg=str("Unable to describe vserver group attribute, error:{0}".format(e))) - module.exit_json(changed=True, vserver_group=get_info(current_vserver_group)) - else: - try: - current_vserver_group = slb.create_vserver_group(load_balancer_id, vserver_group_name, backend_servers) - except Exception as e: - module.fail_json(msg=str("Unable to create vserver group error:{0}".format(e))) - module.exit_json(changed=True, vserver_group=get_info(current_vserver_group)) - if not current_vserver_group: - module.fail_json(msg="The specified vserver group is not exist. Please check your vserver_group_id and try again.") - elif state == "list": - module.exit_json(changed=True, vserver_group=get_info(current_vserver_group)) - elif state == 'absent': - if backend_servers: - try: - current_vserver_group = current_vserver_group.remove_backend_servers(backend_servers) - except Exception as e: - module.fail_json(msg=str("Unable to remove vserver group backend server, error:{0}".format(e))) - module.exit_json(changed=True, vserver_group=get_info(current_vserver_group)) - else: - try: - changed = current_vserver_group.delete() - except Exception as e: - module.fail_json(msg=str("Unable to delete vserver group, error:{0}".format(e))) - module.exit_json(changed=changed, vserver_group=get_info(current_vserver_group)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_vpc.py b/lib/ansible/modules/cloud/alicloud/_alicloud_vpc.py deleted file mode 100644 index ebd90637..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_vpc.py +++ /dev/null @@ -1,277 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: alicloud_vpc -version_added: "1.0.9" -short_description: Create, Query or Delete Vpc. Query Vswitch. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix 'ali' will be more concise - alternative: Use M(ali_vpc) instead -description: - - Create, Query or Delete Vpc, and Query vswitch which in it. -options: - state: - description: - - Whether or not to create, delete or query VPC. - choices: ['present', 'absent', 'list'] - default: 'present' - vpc_name: - description: - - The name of VPC, which is a string of 2 to 128 Chinese or English characters. It must begin with an - uppercase/lowercase letter or a Chinese character and can contain numerals, "_" or "-". - It cannot begin with http:// or https://. - aliases: [ 'name' ] - description: - description: - - The description of VPC, which is a string of 2 to 256 characters. It cannot begin with http:// or https://. - cidr_block: - description: - - The CIDR block representing the vpc. The value can be subnet block of its choices. It is required when creating a vpc. - default: '172.16.0.0/12' - choices: ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'] - aliases: [ 'cidr' ] - user_cidr: - description: - - User custom cidr in the VPC. Multiple cidr should be separated by comma, and no more than three. - vpc_id: - description: - - The ID of a VPC. It required when managing an existing VPC. Such as deleting vpc and querying vpc attribute. - is_default: - description: - - When retrieving vpc, it can mark the VPC is created by system. - type: bool -notes: - - There will be launch a virtual router along with creating a vpc successfully. - - There is only one virtual router in one vpc and one route table in one virtual router. -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" - -""" - -EXAMPLES = """ -# -# provisioning to create vpc in VPC -# - -# basic provisioning example to create vpc in VPC -- name: create vpc - hosts: localhost - connection: local - vars: - alicloud_region: cn-hongkong - state: present - cidr_block: 192.168.0.0/16 - vpc_name: Demo_VPC - description: Demo VPC - tasks: - - name: create vpc - alicloud_vpc: - alicloud_region: '{{ alicloud_region }}' - state: '{{ state }}' - cidr_block: '{{ cidr_block }}' - vpc_name: '{{ vpc_name }}' - description: '{{ description }}' - register: result - - debug: var=result - -# basic provisioning example to delete vpc -- name: delete vpc - hosts: localhost - connection: local - vars: - alicloud_region: cn-hongkong - tasks: - - name: delete vpc - alicloud_vpc: - alicloud_region: '{{ alicloud_region }}' - state: absent - vpc_id: xxxxxxxxxx - register: result - - debug: var=result - -""" - -RETURN = ''' -vpc: - description: info about the VPC that was created or deleted - returned: always - type: complex - contains: - cidr_block: - description: The CIDR of the VPC - returned: always - type: string - sample: 10.0.0.0/8 - creation_time: - description: The time the VPC was created. - returned: always - type: string - sample: 2018-06-24T15:14:45Z - description: - description: The VPC description. - returned: always - type: string - sample: "my ansible vpc" - id: - description: alias of 'vpc_id'. - returned: always - type: string - sample: vpc-c2e00da5 - is_default: - description: indicates whether this is the default VPC - returned: always - type: bool - sample: false - state: - description: state of the VPC - returned: always - type: string - sample: available - tags: - description: tags attached to the VPC, includes name - returned: always - type: complex - sample: - user_cidrs: - description: The custom CIDR of the VPC - returned: always - type: list - sample: [] - vpc_id: - description: VPC resource id - returned: always - type: string - sample: vpc-c2e00da5 - vpc_name: - description: Name of the VPC - returned: always - type: string - sample: my-vpc - vrouter_id: - description: The ID of virtual router which in the VPC - returned: always - type: string - sample: available - vswitch_ids: - description: List IDs of virtual switch which in the VPC - returned: always - type: list - sample: [vsw-123cce3, vsw-34cet4v] -''' - -import time -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import VPCResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - state=dict(default='present', choices=['present', 'absent']), - cidr_block=dict(default='172.16.0.0/16', aliases=['cidr']), - user_cidrs=dict(type='list'), - vpc_name=dict(aliases=['name']), - description=dict(), - vpc_id=dict(), - is_default=dict(type='bool'), - )) - - module = AnsibleModule(argument_spec=argument_spec) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module ali_vpc.') - - vpc_conn = vpc_connect(module) - - # Get values of variable - state = module.params['state'] - vpc_id = module.params['vpc_id'] - vpc_name = module.params['vpc_name'] - description = module.params['description'] - user_cidrs = module.params['user_cidrs'] - - if str(description).startswith('http://') or str(description).startswith('https://'): - module.fail_json(msg='description can not start with http:// or https://') - if str(vpc_name).startswith('http://') or str(vpc_name).startswith('https://'): - module.fail_json(msg='vpc_name can not start with http:// or https://') - - changed = False - vpc = None - - if vpc_id: - try: - vpc = vpc_conn.get_vpc_attribute(vpc_id) - except VPCResponseError as e: - module.fail_json(msg='Retrieving vpc by id {0} got an error: {1}'.format(vpc_id, e)) - - if state == 'absent': - if not vpc: - module.exit_json(changed=changed, vpc={}) - - try: - module.exit_json(changed=vpc.delete(), vpc={}) - except VPCResponseError as ex: - module.fail_json(msg='Unable to delete vpc {0}, error: {1}'.format(vpc.id, ex)) - - if not vpc: - params = module.params - params['client_token'] = "Ansible-Alicloud-%s-%s" % (hash(str(module.params)), str(time.time())) - try: - vpc = vpc_conn.create_vpc(params) - module.exit_json(changed=True, vpc=vpc.get().read()) - except VPCResponseError as e: - module.fail_json(msg='Unable to create vpc, error: {0}'.format(e)) - - if not vpc_name: - vpc_name = vpc.vpc_name - if not description: - description = vpc.description - if not user_cidrs: - user_cidrs = vpc.user_cidrs['user_cidr'] - - try: - if vpc.modify(vpc_name, description, user_cidrs): - changed = True - module.exit_json(changed=changed, vpc=vpc.get().read()) - except VPCResponseError as e: - module.fail_json(msg='Unable to modify vpc {0}, error: {1}'.format(vpc_id, e)) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/modules/cloud/alicloud/_alicloud_vswitch.py b/lib/ansible/modules/cloud/alicloud/_alicloud_vswitch.py deleted file mode 100644 index 402bbe37..00000000 --- a/lib/ansible/modules/cloud/alicloud/_alicloud_vswitch.py +++ /dev/null @@ -1,299 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2017-present Alibaba Group Holding Limited. He Guimin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see http://www.gnu.org/licenses/. - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['deprecated'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: alicloud_vswitch -version_added: "1.0.9" -short_description: Create, Query or Delete Vswitch. -description: - - Create, Query or Delete vswitch which in the vpc. -deprecated: - removed_in: "1.5.0" - why: Alibaba Cloud module name prefix "ali" will be more concise. - alternative: Use M(ali_vswitch) instead. -options: - state: - description: - - Whether or not to create, delete or query vswitch. - choices: ['present', 'absent', 'list'] - default: 'present' - alicloud_zone: - description: - - Aliyun availability zone ID which to launch the vswitch or list vswitches. - It is required when creating a vswitch. - aliases: [ 'zone_id', 'zone' ] - vpc_id: - description: - - The ID of a VPC to which that Vswitch belongs. It is required when creating a vswitch. - cidr_block: - description: - - The CIDR block representing the Vswitch e.g. 10.0.0.0/8. The value must be sub cidr_block of Vpc. - It is required when creating a vswitch. - vswitch_name: - description: - - The name of vswitch, which is a string of 2 to 128 Chinese or English characters. It must begin with an - uppercase/lowercase letter or a Chinese character and can contain numerals, "_" or "-". - It cannot begin with http:// or https://. - aliases: [ 'name', 'subnet_name' ] - description: - description: - - The description of vswitch, which is a string of 2 to 256 characters. It cannot begin with http:// or https://. - vswitch_id: - description: - - VSwitch ID. It is used to manage the existing VSwitch. Such as modifying VSwitch's attribute or deleting VSwitch. - aliases: [ 'subnet_id' ] - is_default: - description: - - When retrieving VSwitch, it can mark the VSwitch is created by system. - type: bool -requirements: - - "python >= 2.6" - - "footmark >= 1.1.16" -extends_documentation_fragment: - - alicloud -author: - - "He Guimin (@xiaozhu36)" - -""" - -EXAMPLES = """ - -# basic provisioning example to create vswitch -- name: create vswitch - hosts: localhost - connection: local - vars: - alicloud_region: cn-hongkong - vpc_id: xxxxxxxxxx - alicloud_zone: cn-hongkong-b - cidr_block: '172.16.0.0/24' - name: 'Demo_VSwitch' - description: 'akashhttp://' - state: present - tasks: - - name: create vswitch - alicloud_vswitch: - alicloud_region: '{{ alicloud_region }}' - cidr_block: '{{ cidr_blok }}' - name: '{{ name }}' - description: '{{ description }}' - vpc_id: '{{ vpc_id }}' - state: '{{ state }}' - register: result - - debug: var=result - -# basic provisioning example to delete vswitch -- name: delete vswitch - hosts: localhost - connection: local - vars: - alicloud_region: cn-hongkong - vpc_id: xxxxxxxxxx - vswitch_id: xxxxxxxxxx - state: absent - tasks: - - name: delete vswitch - alicloud_vswitch: - alicloud_region: '{{ alicloud_region }}' - vpc_id: '{{ vpc_id }}' - vswitch_id: '{{ vswitch_id }}' - state: '{{ state }}' - register: result - - debug: var=result - -""" - -RETURN = ''' -vswitch: - description: Dictionary of vswitch values - returned: always - type: complex - contains: - id: - description: alias of vswitch_id - returned: always - type: string - sample: vsw-b883b2c4 - cidr_block: - description: The IPv4 CIDR of the VSwitch - returned: always - type: string - sample: "10.0.0.0/16" - availability_zone: - description: Availability zone of the VSwitch - returned: always - type: string - sample: cn-beijing-a - state: - description: state of the Subnet - returned: always - type: string - sample: available - is_default: - description: indicates whether this is the default VSwitch - returned: always - type: bool - sample: false - tags: - description: tags attached to the Subnet, includes name - returned: always - type: dict - sample: {"Name": "My Subnet", "env": "staging"} - vpc_id: - description: the id of the VPC where this VSwitch exists - returned: always - type: string - sample: vpc-67236184 - available_ip_address_count: - description: number of available IPv4 addresses - returned: always - type: string - sample: 250 - vswitch_id: - description: VSwitch resource id - returned: always - type: string - sample: vsw-b883b2c4 - subnet_id: - description: alias of vswitch_id - returned: always - type: string - sample: vsw-b883b2c4 - vswitch_name: - description: VSwitch resource name - returned: always - type: string - sample: my-vsw - creation_time: - description: The time the VSwitch was created. - returned: always - type: string - sample: 2018-06-24T15:14:45Z -''' - -import time, inspect -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect - -HAS_FOOTMARK = False - -try: - from footmark.exception import VPCResponseError - HAS_FOOTMARK = True -except ImportError: - HAS_FOOTMARK = False - - -def uniquely_find_vswitch(connection, module): - - vswitch_id = module.params["vswitch_id"] - cidr_block = module.params['cidr_block'] - vpc_id = module.params['vpc_id'] - - try: - if not vswitch_id and not cidr_block and not vpc_id: - return None - - vsws = connection.get_all_vswitches(module.params) - for v in vsws: - if vswitch_id and v.vswitch_id == vswitch_id: - return v - if cidr_block == v.cidr_block: - return v - return None - - except Exception as e: - module.fail_json(msg=e.message) - - -def main(): - argument_spec = ecs_argument_spec() - argument_spec.update(dict( - state=dict(type='str', default='present', choices=['present', 'absent']), - cidr_block=dict(type='str'), - description=dict(type='str'), - availability_zone=dict(aliases=['alicloud_zone']), - vpc_id=dict(type='str'), - vswitch_name=dict(aliases=['name', 'subnet_name']), - vswitch_id=dict(type='str', aliases=['subnet_id', 'id']), - )) - - module = AnsibleModule(argument_spec=argument_spec, - required_if=([ - ('state', 'absent', ['vswitch_id']) - ]) - ) - - if HAS_FOOTMARK is False: - module.fail_json(msg='footmark required for the module ali_vswitch.') - - vpc = vpc_connect(module) - - # Get values of variable - state = module.params['state'] - vswitch_name = module.params['vswitch_name'] - description = module.params['description'] - - changed = False - vswitch = uniquely_find_vswitch(vpc, module) - - if state == 'absent': - if not vswitch: - module.exit_json(changed=changed, vswitch={}) - try: - changed = vswitch.delete() - module.exit_json(changed=changed, vswitch={}) - except VPCResponseError as ex: - module.fail_json(msg='Unable to delete vswitch: {0}, error: {1}'.format(vswitch.id, ex)) - - if str(description).startswith('http://') or str(description).startswith('https://'): - module.fail_json(msg='description can not start with http:// or https://') - - if str(vswitch_name).startswith('http://') or str(vswitch_name).startswith('https://'): - module.fail_json(msg='vswitch_name can not start with http:// or https://') - - if not vswitch: - try: - params = module.params - params['client_token'] = "Ansible-Alicloud-{0}-{1}".format(hash(str(module.params)), str(time.time())) - vswitch = vpc.create_vswitch(params) - module.exit_json(changed=True, vswitch=vswitch.get().read()) - except VPCResponseError as e: - module.fail_json(msg='Unable to create VSwitch, error: {0}'.format(e)) - - if not vswitch_name: - vswitch_name = vswitch.vswitch_name - if not description: - description = vswitch.description - try: - if vswitch.modify(name=vswitch_name, description=description): - changed = True - except VPCResponseError as e: - module.fail_json(msg='Unable to modify vswitch attribute, error: {0}'.format(e)) - - module.exit_json(changed=changed, vswitch=vswitch.get().read()) - - -if __name__ == '__main__': - main() diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py deleted file mode 100644 index ae8ccff5..00000000 --- a/lib/ansible/utils/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# (c) 2012-2014, Michael DeHaan -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type diff --git a/lib/setup.py b/lib/setup.py deleted file mode 100644 index 8d1d863d..00000000 --- a/lib/setup.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -# Always prefer setuptools over distutils - -try: - from setuptools import setup - - extra = dict(test_suite="tests.test.suite", include_package_data=True) -except ImportError: - from distutils.core import setup - - extra = {} - -NAME = "ansible_alicloud_module_utils" -DESCRIPTION = "The dependence of Ansible Provider Alicloud modules." -AUTHOR = "xiaozhu" -AUTHOR_EMAIL = "heguimin36@163.com" - -VERSION = '1.5.0' - -setup( - name=NAME, - - version=VERSION, - description=DESCRIPTION, - - # Author details - author=AUTHOR, - author_email=AUTHOR_EMAIL, - - # Choose your license - license='MIT', - - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - 'Development Status :: 3 - Alpha', - - # Indicate who your project is intended for - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Build Tools', - - # Pick your license as you wish (should match "license" above) - 'License :: OSI Approved :: MIT License', - - # Specify the Python versions you support here. In particular, ensure - # that you indicate whether you support Python 2. - 'Programming Language :: Python :: 3.6', - ], - - packages=['ansible.module_utils'], - include_package_data=True, - install_requires=['ansible', 'footmark>=1.20.0'] -) diff --git a/plugins/README.md b/plugins/README.md new file mode 100644 index 00000000..6541cf7c --- /dev/null +++ b/plugins/README.md @@ -0,0 +1,31 @@ +# Collections Plugins Directory + +This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that +is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that +would contain module utils and modules respectively. + +Here is an example directory of the majority of plugins currently supported by Ansible: + +``` +└── plugins + ├── action + ├── become + ├── cache + ├── callback + ├── cliconf + ├── connection + ├── filter + ├── httpapi + ├── inventory + ├── lookup + ├── module_utils + ├── modules + ├── netconf + ├── shell + ├── strategy + ├── terminal + ├── test + └── vars +``` + +A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible/2.9/plugins/plugins.html). \ No newline at end of file diff --git a/lib/ansible/modules/__init__.py b/plugins/__init__.py similarity index 100% rename from lib/ansible/modules/__init__.py rename to plugins/__init__.py diff --git a/lib/ansible/modules/cloud/alicloud/__init__.py b/plugins/doc_fragments/__init__.py similarity index 100% rename from lib/ansible/modules/cloud/alicloud/__init__.py rename to plugins/doc_fragments/__init__.py diff --git a/lib/ansible/utils/module_docs_fragments/alicloud.py b/plugins/doc_fragments/alicloud.py similarity index 100% rename from lib/ansible/utils/module_docs_fragments/alicloud.py rename to plugins/doc_fragments/alicloud.py diff --git a/examples/alicloud-ecs-vpc/LICENSE.md b/plugins/examples/alicloud-ecs-vpc/LICENSE.md similarity index 100% rename from examples/alicloud-ecs-vpc/LICENSE.md rename to plugins/examples/alicloud-ecs-vpc/LICENSE.md diff --git a/examples/alicloud-ecs-vpc/README.md b/plugins/examples/alicloud-ecs-vpc/README.md similarity index 100% rename from examples/alicloud-ecs-vpc/README.md rename to plugins/examples/alicloud-ecs-vpc/README.md diff --git a/examples/alicloud-ecs-vpc/alicloud.yml b/plugins/examples/alicloud-ecs-vpc/alicloud.yml similarity index 100% rename from examples/alicloud-ecs-vpc/alicloud.yml rename to plugins/examples/alicloud-ecs-vpc/alicloud.yml diff --git a/examples/alicloud-ecs-vpc/destroy.yml b/plugins/examples/alicloud-ecs-vpc/destroy.yml similarity index 100% rename from examples/alicloud-ecs-vpc/destroy.yml rename to plugins/examples/alicloud-ecs-vpc/destroy.yml diff --git a/examples/alicloud-ecs-vpc/group_vars/all b/plugins/examples/alicloud-ecs-vpc/group_vars/all similarity index 100% rename from examples/alicloud-ecs-vpc/group_vars/all rename to plugins/examples/alicloud-ecs-vpc/group_vars/all diff --git a/examples/alicloud-ecs-vpc/roles/disk/tasks/main.yml b/plugins/examples/alicloud-ecs-vpc/roles/disk/tasks/main.yml similarity index 100% rename from examples/alicloud-ecs-vpc/roles/disk/tasks/main.yml rename to plugins/examples/alicloud-ecs-vpc/roles/disk/tasks/main.yml diff --git a/examples/alicloud-ecs-vpc/roles/instance/tasks/main.yml b/plugins/examples/alicloud-ecs-vpc/roles/instance/tasks/main.yml similarity index 100% rename from examples/alicloud-ecs-vpc/roles/instance/tasks/main.yml rename to plugins/examples/alicloud-ecs-vpc/roles/instance/tasks/main.yml diff --git a/examples/alicloud-ecs-vpc/roles/security_group/tasks/main.yml b/plugins/examples/alicloud-ecs-vpc/roles/security_group/tasks/main.yml similarity index 100% rename from examples/alicloud-ecs-vpc/roles/security_group/tasks/main.yml rename to plugins/examples/alicloud-ecs-vpc/roles/security_group/tasks/main.yml diff --git a/examples/alicloud-ecs-vpc/roles/vpc/tasks/main.yml b/plugins/examples/alicloud-ecs-vpc/roles/vpc/tasks/main.yml similarity index 100% rename from examples/alicloud-ecs-vpc/roles/vpc/tasks/main.yml rename to plugins/examples/alicloud-ecs-vpc/roles/vpc/tasks/main.yml diff --git a/examples/alicloud-ecs-vpc/roles/vswitch/tasks/main.yml b/plugins/examples/alicloud-ecs-vpc/roles/vswitch/tasks/main.yml similarity index 100% rename from examples/alicloud-ecs-vpc/roles/vswitch/tasks/main.yml rename to plugins/examples/alicloud-ecs-vpc/roles/vswitch/tasks/main.yml diff --git a/examples/alicloud-ecs-vpc/test.yml b/plugins/examples/alicloud-ecs-vpc/test.yml similarity index 100% rename from examples/alicloud-ecs-vpc/test.yml rename to plugins/examples/alicloud-ecs-vpc/test.yml diff --git a/examples/market/LICENSE.md b/plugins/examples/market/LICENSE.md similarity index 100% rename from examples/market/LICENSE.md rename to plugins/examples/market/LICENSE.md diff --git a/examples/market/README.md b/plugins/examples/market/README.md similarity index 100% rename from examples/market/README.md rename to plugins/examples/market/README.md diff --git a/examples/market/create.yml b/plugins/examples/market/create.yml similarity index 100% rename from examples/market/create.yml rename to plugins/examples/market/create.yml diff --git a/examples/market/destroy.yml b/plugins/examples/market/destroy.yml similarity index 100% rename from examples/market/destroy.yml rename to plugins/examples/market/destroy.yml diff --git a/examples/market/group_vars/all b/plugins/examples/market/group_vars/all similarity index 100% rename from examples/market/group_vars/all rename to plugins/examples/market/group_vars/all diff --git a/examples/market/roles/security_group/tasks/main.yml b/plugins/examples/market/roles/security_group/tasks/main.yml similarity index 100% rename from examples/market/roles/security_group/tasks/main.yml rename to plugins/examples/market/roles/security_group/tasks/main.yml diff --git a/examples/market/roles/vpc/tasks/main.yml b/plugins/examples/market/roles/vpc/tasks/main.yml similarity index 100% rename from examples/market/roles/vpc/tasks/main.yml rename to plugins/examples/market/roles/vpc/tasks/main.yml diff --git a/examples/market/roles/vswitch/tasks/main.yml b/plugins/examples/market/roles/vswitch/tasks/main.yml similarity index 100% rename from examples/market/roles/vswitch/tasks/main.yml rename to plugins/examples/market/roles/vswitch/tasks/main.yml diff --git a/examples/petstore/LICENSE.md b/plugins/examples/petstore/LICENSE.md similarity index 100% rename from examples/petstore/LICENSE.md rename to plugins/examples/petstore/LICENSE.md diff --git a/examples/petstore/README.md b/plugins/examples/petstore/README.md similarity index 100% rename from examples/petstore/README.md rename to plugins/examples/petstore/README.md diff --git a/examples/petstore/alicloud.ini b/plugins/examples/petstore/alicloud.ini similarity index 100% rename from examples/petstore/alicloud.ini rename to plugins/examples/petstore/alicloud.ini diff --git a/contrib/inventory/alicloud.py b/plugins/examples/petstore/alicloud.py similarity index 100% rename from contrib/inventory/alicloud.py rename to plugins/examples/petstore/alicloud.py diff --git a/examples/petstore/create.yml b/plugins/examples/petstore/create.yml similarity index 100% rename from examples/petstore/create.yml rename to plugins/examples/petstore/create.yml diff --git a/examples/petstore/delete.yml b/plugins/examples/petstore/delete.yml similarity index 100% rename from examples/petstore/delete.yml rename to plugins/examples/petstore/delete.yml diff --git a/examples/petstore/deploy.yml b/plugins/examples/petstore/deploy.yml similarity index 100% rename from examples/petstore/deploy.yml rename to plugins/examples/petstore/deploy.yml diff --git a/examples/petstore/group_vars/all b/plugins/examples/petstore/group_vars/all similarity index 100% rename from examples/petstore/group_vars/all rename to plugins/examples/petstore/group_vars/all diff --git a/examples/petstore/roles/instance/tasks/main.yml b/plugins/examples/petstore/roles/instance/tasks/main.yml similarity index 100% rename from examples/petstore/roles/instance/tasks/main.yml rename to plugins/examples/petstore/roles/instance/tasks/main.yml diff --git a/examples/petstore/roles/security_group/tasks/main.yml b/plugins/examples/petstore/roles/security_group/tasks/main.yml similarity index 100% rename from examples/petstore/roles/security_group/tasks/main.yml rename to plugins/examples/petstore/roles/security_group/tasks/main.yml diff --git a/examples/petstore/roles/vpc/tasks/main.yml b/plugins/examples/petstore/roles/vpc/tasks/main.yml similarity index 100% rename from examples/petstore/roles/vpc/tasks/main.yml rename to plugins/examples/petstore/roles/vpc/tasks/main.yml diff --git a/examples/petstore/roles/vswitch/tasks/main.yml b/plugins/examples/petstore/roles/vswitch/tasks/main.yml similarity index 100% rename from examples/petstore/roles/vswitch/tasks/main.yml rename to plugins/examples/petstore/roles/vswitch/tasks/main.yml diff --git a/examples/tags/LICENSE.md b/plugins/examples/tags/LICENSE.md similarity index 100% rename from examples/tags/LICENSE.md rename to plugins/examples/tags/LICENSE.md diff --git a/examples/tags/README.md b/plugins/examples/tags/README.md similarity index 100% rename from examples/tags/README.md rename to plugins/examples/tags/README.md diff --git a/examples/tags/group_vars/all b/plugins/examples/tags/group_vars/all similarity index 100% rename from examples/tags/group_vars/all rename to plugins/examples/tags/group_vars/all diff --git a/examples/tags/tags.yml b/plugins/examples/tags/tags.yml similarity index 100% rename from examples/tags/tags.yml rename to plugins/examples/tags/tags.yml diff --git a/lib/ansible/utils/module_docs_fragments/__init__.py b/plugins/inventory/__init__.py similarity index 100% rename from lib/ansible/utils/module_docs_fragments/__init__.py rename to plugins/inventory/__init__.py diff --git a/lib/ansible/plugins/inventory/alicloud.yml b/plugins/inventory/alicloud.yml similarity index 97% rename from lib/ansible/plugins/inventory/alicloud.yml rename to plugins/inventory/alicloud.yml index 0dd46741..876a7ffd 100644 --- a/lib/ansible/plugins/inventory/alicloud.yml +++ b/plugins/inventory/alicloud.yml @@ -1,4 +1,4 @@ -plugin: alicloud_ecs +plugin: alibaba.alicloud.alicloud_ecs # A list of regions in which to describe ECS instances. # If empty (the default) default this will include all regions, except possibly restricted ones like cn-beijing diff --git a/lib/ansible/plugins/inventory/alicloud_ecs.py b/plugins/inventory/alicloud_ecs.py similarity index 97% rename from lib/ansible/plugins/inventory/alicloud_ecs.py rename to plugins/inventory/alicloud_ecs.py index 96f4429c..597ca071 100644 --- a/lib/ansible/plugins/inventory/alicloud_ecs.py +++ b/plugins/inventory/alicloud_ecs.py @@ -15,7 +15,7 @@ extends_documentation_fragment: - inventory_cache - constructed - - alicloud + - alibaba.alicloud.alicloud description: - Get inventory hosts from Alicloud ECS. - Uses a yaml configuration file that ends with C(alicloud.(yml|yaml)). @@ -26,7 +26,7 @@ plugin: description: Token that ensures this is a source file for the plugin. required: True - choices: ['alicloud_ecs'] + choices: ['alibaba.alicloud.alicloud_ecs'] regions: description: - A list of regions in which to describe ECS instances. @@ -49,12 +49,12 @@ EXAMPLES = ''' # Fetch all hosts in cn-beijing -plugin: alicloud_ecs +plugin: alibaba.alicloud.alicloud_ecs regions: - cn-beijing # Example using filters and specifying the hostname precedence -plugin: alicloud_ecs +plugin: alibaba.alicloud.alicloud_ecs regions: - cn-beijing - cn-qingdao @@ -67,7 +67,7 @@ # Example using constructed features to create groups and set ansible_host -plugin: alicloud_ecs +plugin: alibaba.alicloud.alicloud_ecs # If true make invalid entries a fatal error, otherwise skip and continue # Since it is possible to use facts in the expressions they might not always be available and we ignore those errors by default. @@ -86,7 +86,7 @@ ansible_host: public_ip_address # Example of enabling caching for an individual YAML configuration file -plugin: alicloud_ecs +plugin: alibaba.alicloud.alicloud_ecs cache: yes cache_plugin: jsonfile cache_timeout: 7200 @@ -97,7 +97,7 @@ import os from ansible.errors import AnsibleError from ansible.module_utils._text import to_native, to_text -from ansible.module_utils.alicloud_ecs import connect_to_acs, get_profile +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import connect_to_acs, get_profile from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable from ansible.utils.display import Display @@ -114,7 +114,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): - NAME = 'alicloud_ecs' + NAME = 'alibaba.alicloud.alicloud_ecs' def __init__(self): super(InventoryModule, self).__init__() diff --git a/plugins/inventory/script/__init__.py b/plugins/inventory/script/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/contrib/inventory/alicloud.ini b/plugins/inventory/script/alicloud.ini similarity index 100% rename from contrib/inventory/alicloud.ini rename to plugins/inventory/script/alicloud.ini diff --git a/examples/petstore/alicloud.py b/plugins/inventory/script/alicloud.py similarity index 100% rename from examples/petstore/alicloud.py rename to plugins/inventory/script/alicloud.py diff --git a/plugins/module_utils/__init__.py b/plugins/module_utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/ansible/module_utils/alicloud_ecs.py b/plugins/module_utils/alicloud_ecs.py similarity index 100% rename from lib/ansible/module_utils/alicloud_ecs.py rename to plugins/module_utils/alicloud_ecs.py diff --git a/lib/ansible/module_utils/alicloud_oss.py b/plugins/module_utils/alicloud_oss.py similarity index 100% rename from lib/ansible/module_utils/alicloud_oss.py rename to plugins/module_utils/alicloud_oss.py diff --git a/plugins/modules/__init__.py b/plugins/modules/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/ansible/modules/cloud/alicloud/ali_disk.py b/plugins/modules/ali_disk.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_disk.py rename to plugins/modules/ali_disk.py index 5249e928..ddaed6bf 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_disk.py +++ b/plugins/modules/ali_disk.py @@ -116,7 +116,7 @@ - "python >= 3.6" - "footmark >= 1.18.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" ''' @@ -202,7 +202,7 @@ import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_disk_info.py b/plugins/modules/ali_disk_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_disk_info.py rename to plugins/modules/ali_disk_info.py index 5320416c..d5f081e4 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_disk_info.py +++ b/plugins/modules/ali_disk_info.py @@ -56,7 +56,7 @@ - "python >= 3.6" - "footmark >= 1.19.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -152,7 +152,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_dns_domain.py b/plugins/modules/ali_dns_domain.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_dns_domain.py rename to plugins/modules/ali_dns_domain.py index 29b60c00..cc092165 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_dns_domain.py +++ b/plugins/modules/ali_dns_domain.py @@ -71,7 +71,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -173,7 +173,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, dns_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, dns_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_dns_domain_info.py b/plugins/modules/ali_dns_domain_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_dns_domain_info.py rename to plugins/modules/ali_dns_domain_info.py index 8eb4db89..02e5e4b3 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_dns_domain_info.py +++ b/plugins/modules/ali_dns_domain_info.py @@ -49,7 +49,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -136,7 +136,7 @@ from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, dns_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, dns_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_dns_group.py b/plugins/modules/ali_dns_group.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_dns_group.py rename to plugins/modules/ali_dns_group.py index 8b47b396..26409b73 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_dns_group.py +++ b/plugins/modules/ali_dns_group.py @@ -59,7 +59,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -111,7 +111,7 @@ from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, dns_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, dns_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_dns_group_info.py b/plugins/modules/ali_dns_group_info.py similarity index 96% rename from lib/ansible/modules/cloud/alicloud/ali_dns_group_info.py rename to plugins/modules/ali_dns_group_info.py index 20a9db59..e7e2759d 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_dns_group_info.py +++ b/plugins/modules/ali_dns_group_info.py @@ -50,7 +50,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -113,7 +113,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, dns_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, dns_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ecs_tag.py b/plugins/modules/ali_ecs_tag.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_ecs_tag.py rename to plugins/modules/ali_ecs_tag.py index 49a69603..ccaeeeae 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ecs_tag.py +++ b/plugins/modules/ali_ecs_tag.py @@ -53,7 +53,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -93,7 +93,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_eip.py b/plugins/modules/ali_eip.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_eip.py rename to plugins/modules/ali_eip.py index fdf0cafd..ceb2a01c 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_eip.py +++ b/plugins/modules/ali_eip.py @@ -113,7 +113,7 @@ - "python >= 3.6" - "footmark >= 1.13.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" ''' @@ -233,7 +233,7 @@ import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_eip_info.py b/plugins/modules/ali_eip_info.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_eip_info.py rename to plugins/modules/ali_eip_info.py index 035883ec..05541d05 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_eip_info.py +++ b/plugins/modules/ali_eip_info.py @@ -66,7 +66,7 @@ - "python >= 3.6" - "footmark >= 1.13.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -177,7 +177,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_eni.py b/plugins/modules/ali_eni.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_eni.py rename to plugins/modules/ali_eni.py index 81b2537f..0a2472bb 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_eni.py +++ b/plugins/modules/ali_eni.py @@ -96,7 +96,7 @@ - "python >= 3.6" - "footmark >= 1.13.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud notes: - This module identifies and ENI based on either the eni_id or a combination of private_ip_address and vswitch_id. Any of these options will let you specify a particular ENI. @@ -242,7 +242,7 @@ import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_eni_info.py b/plugins/modules/ali_eni_info.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_eni_info.py rename to plugins/modules/ali_eni_info.py index 14b0d994..aaf28b51 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_eni_info.py +++ b/plugins/modules/ali_eni_info.py @@ -62,7 +62,7 @@ - "python >= 3.6" - "footmark >= 1.13.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -177,7 +177,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ess_configuration.py b/plugins/modules/ali_ess_configuration.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_ess_configuration.py rename to plugins/modules/ali_ess_configuration.py index b37dfc35..09e825a0 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ess_configuration.py +++ b/plugins/modules/ali_ess_configuration.py @@ -128,7 +128,7 @@ - "python >= 2.6" - "footmark >= 1.3.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -230,7 +230,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ess_group.py b/plugins/modules/ali_ess_group.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_ess_group.py rename to plugins/modules/ali_ess_group.py index 789ceba2..c6dfc941 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ess_group.py +++ b/plugins/modules/ali_ess_group.py @@ -92,7 +92,7 @@ - "python >= 2.6" - "footmark >= 1.3.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -172,7 +172,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ess_instance.py b/plugins/modules/ali_ess_instance.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_ess_instance.py rename to plugins/modules/ali_ess_instance.py index c1316528..01022981 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ess_instance.py +++ b/plugins/modules/ali_ess_instance.py @@ -64,7 +64,7 @@ - If both I(instance_ids) and I(creation_type) are not specified, the module will remove all of ECS instnaces in the specified Scaling Group when C(state=absent). extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -110,7 +110,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ess_rule.py b/plugins/modules/ali_ess_rule.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_ess_rule.py rename to plugins/modules/ali_ess_rule.py index f1b53aca..9eeb1bc5 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ess_rule.py +++ b/plugins/modules/ali_ess_rule.py @@ -83,7 +83,7 @@ - "python >= 2.6" - "footmark >= 1.3.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -153,7 +153,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ess_task.py b/plugins/modules/ali_ess_task.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_ess_task.py rename to plugins/modules/ali_ess_task.py index 197f12ec..35cb30b4 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ess_task.py +++ b/plugins/modules/ali_ess_task.py @@ -112,7 +112,7 @@ - "python >= 2.6" - "footmark >= 1.3.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -184,7 +184,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ess_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_image.py b/plugins/modules/ali_image.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_image.py rename to plugins/modules/ali_image.py index bb6ade90..178cbbd1 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_image.py +++ b/plugins/modules/ali_image.py @@ -100,7 +100,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" ''' @@ -171,7 +171,7 @@ ''' import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_image_info.py b/plugins/modules/ali_image_info.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_image_info.py rename to plugins/modules/ali_image_info.py index 095117f8..5827bc4c 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_image_info.py +++ b/plugins/modules/ali_image_info.py @@ -54,7 +54,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -165,7 +165,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_instance.py b/plugins/modules/ali_instance.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_instance.py rename to plugins/modules/ali_instance.py index 5f7f9d7a..551a5d35 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_instance.py +++ b/plugins/modules/ali_instance.py @@ -245,7 +245,7 @@ - "python >= 3.6" - "footmark >= 1.19.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -613,7 +613,7 @@ import time import traceback from ansible.module_utils.basic import AnsibleModule, missing_required_lib -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect HAS_FOOTMARK = False FOOTMARK_IMP_ERR = None diff --git a/lib/ansible/modules/cloud/alicloud/ali_instance_info.py b/plugins/modules/ali_instance_info.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_instance_info.py rename to plugins/modules/ali_instance_info.py index 9a29def4..0775fc26 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_instance_info.py +++ b/plugins/modules/ali_instance_info.py @@ -77,7 +77,7 @@ - "python >= 3.6" - "footmark >= 1.13.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -356,7 +356,7 @@ import traceback from ansible.module_utils.basic import AnsibleModule, missing_required_lib -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect HAS_FOOTMARK = False FOOTMARK_IMP_ERR = None diff --git a/lib/ansible/modules/cloud/alicloud/ali_instance_type_facts.py b/plugins/modules/ali_instance_type_facts.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_instance_type_facts.py rename to plugins/modules/ali_instance_type_facts.py index eae0ec6e..9e0ed69b 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_instance_type_facts.py +++ b/plugins/modules/ali_instance_type_facts.py @@ -59,7 +59,7 @@ - "python >= 2.6" - "footmark >= 1.1.16" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -138,7 +138,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, ecs_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_market_product_info.py b/plugins/modules/ali_market_product_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_market_product_info.py rename to plugins/modules/ali_market_product_info.py index 169c36c8..40fc8d64 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_market_product_info.py +++ b/plugins/modules/ali_market_product_info.py @@ -79,7 +79,7 @@ - "python >= 3.6" - "footmark >= 1.18.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -147,7 +147,7 @@ sample: m-2ze0ua7jvif73kxxxxx ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, market_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, market_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_oos_execution.py b/plugins/modules/ali_oos_execution.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_oos_execution.py rename to plugins/modules/ali_oos_execution.py index dce81590..7e321be7 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_oos_execution.py +++ b/plugins/modules/ali_oos_execution.py @@ -139,7 +139,7 @@ - "python >= 3.6" - "footmark >= 1.20.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" - "Li Xue (@lixue323)" @@ -323,7 +323,7 @@ import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, oos_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, oos_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_oos_execution_info.py b/plugins/modules/ali_oos_execution_info.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_oos_execution_info.py rename to plugins/modules/ali_oos_execution_info.py index 93739e43..dff1d982 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_oos_execution_info.py +++ b/plugins/modules/ali_oos_execution_info.py @@ -49,7 +49,7 @@ - "python >= 3.6" - "footmark >= 1.20.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" - "Li Xue (@lixue323)" @@ -197,7 +197,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, oos_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, oos_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_oos_template.py b/plugins/modules/ali_oos_template.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_oos_template.py rename to plugins/modules/ali_oos_template.py index 8188a28e..983da52b 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_oos_template.py +++ b/plugins/modules/ali_oos_template.py @@ -74,7 +74,7 @@ - "python >= 3.6" - "footmark >= 1.20.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" - "Li Xue (@lixue323)" @@ -218,7 +218,7 @@ import time import json from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, oos_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, oos_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_oos_template_info.py b/plugins/modules/ali_oos_template_info.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_oos_template_info.py rename to plugins/modules/ali_oos_template_info.py index b17d8190..4899d636 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_oos_template_info.py +++ b/plugins/modules/ali_oos_template_info.py @@ -53,7 +53,7 @@ - "python >= 3.6" - "footmark >= 1.20.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" - "Li Xue (@lixue323)" @@ -198,7 +198,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, oos_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, oos_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_oss_bucket.py b/plugins/modules/ali_oss_bucket.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_oss_bucket.py rename to plugins/modules/ali_oss_bucket.py index d8c1fece..6962083d 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_oss_bucket.py +++ b/plugins/modules/ali_oss_bucket.py @@ -49,7 +49,7 @@ - "python >= 2.6" - "footmark >= 1.1.16" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" ''' diff --git a/lib/ansible/modules/cloud/alicloud/ali_oss_bucket_info.py b/plugins/modules/ali_oss_bucket_info.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_oss_bucket_info.py rename to plugins/modules/ali_oss_bucket_info.py index 7a661ceb..152a8b83 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_oss_bucket_info.py +++ b/plugins/modules/ali_oss_bucket_info.py @@ -44,7 +44,7 @@ - "python >= 2.6" - "footmark" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/alicloud/ali_oss_object.py b/plugins/modules/ali_oss_object.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_oss_object.py rename to plugins/modules/ali_oss_object.py index d1cf4ba1..22bf91f7 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_oss_object.py +++ b/plugins/modules/ali_oss_object.py @@ -77,7 +77,7 @@ - "python >= 2.6" - "footmark >= 1.1.16" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" ''' diff --git a/lib/ansible/modules/cloud/alicloud/ali_oss_object_info.py b/plugins/modules/ali_oss_object_info.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_oss_object_info.py rename to plugins/modules/ali_oss_object_info.py index 80186321..bfc9b698 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_oss_object_info.py +++ b/plugins/modules/ali_oss_object_info.py @@ -43,7 +43,7 @@ - "python >= 2.6" - "footmark" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_access_key.py b/plugins/modules/ali_ram_access_key.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_ram_access_key.py rename to plugins/modules/ali_ram_access_key.py index 8148a253..45532e4f 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_access_key.py +++ b/plugins/modules/ali_ram_access_key.py @@ -62,7 +62,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -116,7 +116,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_access_key_info.py b/plugins/modules/ali_ram_access_key_info.py similarity index 95% rename from lib/ansible/modules/cloud/alicloud/ali_ram_access_key_info.py rename to plugins/modules/ali_ram_access_key_info.py index 4bb500b8..ebf4ef6c 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_access_key_info.py +++ b/plugins/modules/ali_ram_access_key_info.py @@ -46,7 +46,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -84,7 +84,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_group.py b/plugins/modules/ali_ram_group.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_ram_group.py rename to plugins/modules/ali_ram_group.py index c53c2b80..c73cba4c 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_group.py +++ b/plugins/modules/ali_ram_group.py @@ -69,7 +69,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -143,7 +143,7 @@ import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_group_info.py b/plugins/modules/ali_ram_group_info.py similarity index 96% rename from lib/ansible/modules/cloud/alicloud/ali_ram_group_info.py rename to plugins/modules/ali_ram_group_info.py index a754a5ff..6bf89caa 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_group_info.py +++ b/plugins/modules/ali_ram_group_info.py @@ -44,7 +44,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -92,7 +92,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_login_profile.py b/plugins/modules/ali_ram_login_profile.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_ram_login_profile.py rename to plugins/modules/ali_ram_login_profile.py index de6306e0..713d48bf 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_login_profile.py +++ b/plugins/modules/ali_ram_login_profile.py @@ -70,7 +70,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -122,7 +122,7 @@ sample: Alice ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_login_profile_info.py b/plugins/modules/ali_ram_login_profile_info.py similarity index 95% rename from lib/ansible/modules/cloud/alicloud/ali_ram_login_profile_info.py rename to plugins/modules/ali_ram_login_profile_info.py index ffd3a3ee..86038a48 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_login_profile_info.py +++ b/plugins/modules/ali_ram_login_profile_info.py @@ -46,7 +46,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -85,7 +85,7 @@ sample: Alice ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_policy.py b/plugins/modules/ali_ram_policy.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_ram_policy.py rename to plugins/modules/ali_ram_policy.py index 0264a597..3f5b7840 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_policy.py +++ b/plugins/modules/ali_ram_policy.py @@ -86,7 +86,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -193,7 +193,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_policy_info.py b/plugins/modules/ali_ram_policy_info.py similarity index 96% rename from lib/ansible/modules/cloud/alicloud/ali_ram_policy_info.py rename to plugins/modules/ali_ram_policy_info.py index 16085448..7bf6db66 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_policy_info.py +++ b/plugins/modules/ali_ram_policy_info.py @@ -44,7 +44,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -106,7 +106,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_role.py b/plugins/modules/ali_ram_role.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_ram_role.py rename to plugins/modules/ali_ram_role.py index 7f66a8ac..dfcd6a7d 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_role.py +++ b/plugins/modules/ali_ram_role.py @@ -70,7 +70,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -133,7 +133,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_role_info.py b/plugins/modules/ali_ram_role_info.py similarity index 96% rename from lib/ansible/modules/cloud/alicloud/ali_ram_role_info.py rename to plugins/modules/ali_ram_role_info.py index 55834730..db088a00 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_role_info.py +++ b/plugins/modules/ali_ram_role_info.py @@ -44,7 +44,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -95,7 +95,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_user.py b/plugins/modules/ali_ram_user.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_ram_user.py rename to plugins/modules/ali_ram_user.py index ea46999a..dd9325d4 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_user.py +++ b/plugins/modules/ali_ram_user.py @@ -79,7 +79,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -165,7 +165,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ram_user_info.py b/plugins/modules/ali_ram_user_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_ram_user_info.py rename to plugins/modules/ali_ram_user_info.py index 053b3272..e11f7a1c 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ram_user_info.py +++ b/plugins/modules/ali_ram_user_info.py @@ -49,7 +49,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -128,7 +128,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ram_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_rds_account.py b/plugins/modules/ali_rds_account.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_rds_account.py rename to plugins/modules/ali_rds_account.py index b1f8e8d4..adfc866e 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_rds_account.py +++ b/plugins/modules/ali_rds_account.py @@ -101,7 +101,7 @@ - "python >= 3.6" - "footmark >= 1.16.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud """ EXAMPLES = """ @@ -201,7 +201,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_rds_account_info.py b/plugins/modules/ali_rds_account_info.py similarity index 96% rename from lib/ansible/modules/cloud/alicloud/ali_rds_account_info.py rename to plugins/modules/ali_rds_account_info.py index 7ba58b46..72243d1a 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_rds_account_info.py +++ b/plugins/modules/ali_rds_account_info.py @@ -50,7 +50,7 @@ - "python >= 3.6" - "footmark >= 1.16.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud """ EXAMPLES = """ @@ -119,7 +119,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, rds_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import get_acs_connection_info, ecs_argument_spec, rds_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_rds_backup.py b/plugins/modules/ali_rds_backup.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_rds_backup.py rename to plugins/modules/ali_rds_backup.py index 81efe229..3f679f0c 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_rds_backup.py +++ b/plugins/modules/ali_rds_backup.py @@ -81,7 +81,7 @@ - "python >= 3.6" - "footmark >= 1.16.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud """ EXAMPLES = """ @@ -177,7 +177,7 @@ """ from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_rds_backup_info.py b/plugins/modules/ali_rds_backup_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_rds_backup_info.py rename to plugins/modules/ali_rds_backup_info.py index ae9bbd81..db6e549e 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_rds_backup_info.py +++ b/plugins/modules/ali_rds_backup_info.py @@ -57,7 +57,7 @@ - "python >= 3.6" - "footmark >= 1.16.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -148,7 +148,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_rds_database.py b/plugins/modules/ali_rds_database.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_rds_database.py rename to plugins/modules/ali_rds_database.py index 478597c3..6991b09a 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_rds_database.py +++ b/plugins/modules/ali_rds_database.py @@ -104,7 +104,7 @@ - "python >= 3.6" - "footmark >= 1.16.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -192,7 +192,7 @@ import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_rds_database_info.py b/plugins/modules/ali_rds_database_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_rds_database_info.py rename to plugins/modules/ali_rds_database_info.py index 4ddd8d35..4249701a 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_rds_database_info.py +++ b/plugins/modules/ali_rds_database_info.py @@ -56,7 +56,7 @@ - "python >= 3.6" - "footmark >= 1.16.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -129,7 +129,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_rds_instance.py b/plugins/modules/ali_rds_instance.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_rds_instance.py rename to plugins/modules/ali_rds_instance.py index 61538ebf..733db723 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_rds_instance.py +++ b/plugins/modules/ali_rds_instance.py @@ -170,7 +170,7 @@ - "python >= 3.6" - "footmark >= 1.16.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -454,7 +454,7 @@ import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect, vpc_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect, vpc_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_rds_instance_info.py b/plugins/modules/ali_rds_instance_info.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_rds_instance_info.py rename to plugins/modules/ali_rds_instance_info.py index a037532a..e4b7a724 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_rds_instance_info.py +++ b/plugins/modules/ali_rds_instance_info.py @@ -54,7 +54,7 @@ - "python >= 3.6" - "footmark >= 1.16.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -296,7 +296,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, rds_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ros_stack.py b/plugins/modules/ali_ros_stack.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_ros_stack.py rename to plugins/modules/ali_ros_stack.py index e43a7b55..b19ba04a 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ros_stack.py +++ b/plugins/modules/ali_ros_stack.py @@ -65,7 +65,7 @@ - "python >= 3.6" - "footmark >= 1.20.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud """ EXAMPLES = """ @@ -144,7 +144,7 @@ import json import ruamel.yaml from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ros_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ros_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_ros_stack_info.py b/plugins/modules/ali_ros_stack_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_ros_stack_info.py rename to plugins/modules/ali_ros_stack_info.py index dccaeac4..c3c98ada 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_ros_stack_info.py +++ b/plugins/modules/ali_ros_stack_info.py @@ -55,7 +55,7 @@ - "python >= 3.6" - "footmark >= 1.20.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud """ EXAMPLES = """ @@ -122,7 +122,7 @@ sample: 60 """ from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ros_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ros_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_route_entry.py b/plugins/modules/ali_route_entry.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_route_entry.py rename to plugins/modules/ali_route_entry.py index d114064b..4c2baa49 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_route_entry.py +++ b/plugins/modules/ali_route_entry.py @@ -78,7 +78,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -165,7 +165,7 @@ # import module snippets from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_route_entry_info.py b/plugins/modules/ali_route_entry_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_route_entry_info.py rename to plugins/modules/ali_route_entry_info.py index f4cb4a61..9a0b4afd 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_route_entry_info.py +++ b/plugins/modules/ali_route_entry_info.py @@ -50,7 +50,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -125,7 +125,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_security_group.py b/plugins/modules/ali_security_group.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_security_group.py rename to plugins/modules/ali_security_group.py index 3925e9d6..3bb6ef71 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_security_group.py +++ b/plugins/modules/ali_security_group.py @@ -116,7 +116,7 @@ - "python >= 3.6" - "footmark >= 1.13.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" ''' @@ -241,7 +241,7 @@ import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect try: diff --git a/lib/ansible/modules/cloud/alicloud/ali_security_group_info.py b/plugins/modules/ali_security_group_info.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_security_group_info.py rename to plugins/modules/ali_security_group_info.py index aba9c733..f8550601 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_security_group_info.py +++ b/plugins/modules/ali_security_group_info.py @@ -69,7 +69,7 @@ - "python >= 3.6" - "footmark >= 1.13.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -195,7 +195,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, ecs_connect try: diff --git a/lib/ansible/modules/cloud/alicloud/ali_slb_lb.py b/plugins/modules/ali_slb_lb.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_slb_lb.py rename to plugins/modules/ali_slb_lb.py index 052a2192..fef81355 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_slb_lb.py +++ b/plugins/modules/ali_slb_lb.py @@ -114,7 +114,7 @@ - "python >= 3.6" - "footmark >= 1.16.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" ''' @@ -307,7 +307,7 @@ import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_slb_lb_info.py b/plugins/modules/ali_slb_lb_info.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_slb_lb_info.py rename to plugins/modules/ali_slb_lb_info.py index 8cbf81d6..fd449dc1 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_slb_lb_info.py +++ b/plugins/modules/ali_slb_lb_info.py @@ -66,7 +66,7 @@ - "python >= 3.6" - "footmark >= 1.16.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -254,7 +254,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_slb_listener.py b/plugins/modules/ali_slb_listener.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_slb_listener.py rename to plugins/modules/ali_slb_listener.py index 584fe89e..8741fc50 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_slb_listener.py +++ b/plugins/modules/ali_slb_listener.py @@ -169,7 +169,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -238,7 +238,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect HAS_ECS = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_slb_listener_info.py b/plugins/modules/ali_slb_listener_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_slb_listener_info.py rename to plugins/modules/ali_slb_listener_info.py index 9cc84e0f..eff6f4cd 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_slb_listener_info.py +++ b/plugins/modules/ali_slb_listener_info.py @@ -59,7 +59,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud """ EXAMPLES = """ @@ -90,7 +90,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect HAS_ECS = False HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_slb_server.py b/plugins/modules/ali_slb_server.py similarity index 99% rename from lib/ansible/modules/cloud/alicloud/ali_slb_server.py rename to plugins/modules/ali_slb_server.py index b5006665..d31bf34b 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_slb_server.py +++ b/plugins/modules/ali_slb_server.py @@ -77,7 +77,7 @@ - "python >= 3.6" - "footmark >= 1.19.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -155,7 +155,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect try: from footmark.exception import SLBResponseError diff --git a/lib/ansible/modules/cloud/alicloud/ali_slb_server_info.py b/plugins/modules/ali_slb_server_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_slb_server_info.py rename to plugins/modules/ali_slb_server_info.py index 4ce00e4e..d4d84246 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_slb_server_info.py +++ b/plugins/modules/ali_slb_server_info.py @@ -53,7 +53,7 @@ - "python >= 3.6" - "footmark >= 1.15.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud """ EXAMPLES = ''' @@ -102,7 +102,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect try: from footmark.exception import SLBResponseError diff --git a/lib/ansible/modules/cloud/alicloud/ali_slb_tag.py b/plugins/modules/ali_slb_tag.py similarity index 96% rename from lib/ansible/modules/cloud/alicloud/ali_slb_tag.py rename to plugins/modules/ali_slb_tag.py index ca15f026..13c9b017 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_slb_tag.py +++ b/plugins/modules/ali_slb_tag.py @@ -52,7 +52,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -93,7 +93,7 @@ from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_slb_vsg.py b/plugins/modules/ali_slb_vsg.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_slb_vsg.py rename to plugins/modules/ali_slb_vsg.py index 446d46af..9954ef85 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_slb_vsg.py +++ b/plugins/modules/ali_slb_vsg.py @@ -88,7 +88,7 @@ - "python >= 3.6" - "footmark >= 1.19.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" ''' @@ -201,7 +201,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_slb_vsg_info.py b/plugins/modules/ali_slb_vsg_info.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_slb_vsg_info.py rename to plugins/modules/ali_slb_vsg_info.py index 653b8351..2ba967bc 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_slb_vsg_info.py +++ b/plugins/modules/ali_slb_vsg_info.py @@ -57,7 +57,7 @@ - "python >= 3.6" - "footmark >= 1.19.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -148,7 +148,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_vpc.py b/plugins/modules/ali_vpc.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_vpc.py rename to plugins/modules/ali_vpc.py index 14deb3bf..da1e821e 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_vpc.py +++ b/plugins/modules/ali_vpc.py @@ -100,7 +100,7 @@ - "python >= 3.6" - "footmark >= 1.14.1" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -193,10 +193,9 @@ type: list sample: [vsw-123cce3, vsw-34cet4v] ''' - import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_vpc_info.py b/plugins/modules/ali_vpc_info.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_vpc_info.py rename to plugins/modules/ali_vpc_info.py index 71bb66a0..01055f3e 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_vpc_info.py +++ b/plugins/modules/ali_vpc_info.py @@ -71,7 +71,7 @@ - "python >= 3.6" - "footmark >= 1.14.1" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -170,7 +170,7 @@ sample: [vsw-123cce3, vsw-34cet4v] ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_vpc_tag.py b/plugins/modules/ali_vpc_tag.py similarity index 97% rename from lib/ansible/modules/cloud/alicloud/ali_vpc_tag.py rename to plugins/modules/ali_vpc_tag.py index c345e3c6..978a570c 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_vpc_tag.py +++ b/plugins/modules/ali_vpc_tag.py @@ -55,7 +55,7 @@ - "python >= 3.6" - "footmark >= 1.17.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -96,7 +96,7 @@ from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_vswitch.py b/plugins/modules/ali_vswitch.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_vswitch.py rename to plugins/modules/ali_vswitch.py index 25e32f5b..29d1fde3 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_vswitch.py +++ b/plugins/modules/ali_vswitch.py @@ -89,7 +89,7 @@ - "python >= 3.6" - "footmark >= 1.13.0" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud author: - "He Guimin (@xiaozhu36)" """ @@ -185,7 +185,7 @@ import time from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect HAS_FOOTMARK = False diff --git a/lib/ansible/modules/cloud/alicloud/ali_vswitch_info.py b/plugins/modules/ali_vswitch_info.py similarity index 98% rename from lib/ansible/modules/cloud/alicloud/ali_vswitch_info.py rename to plugins/modules/ali_vswitch_info.py index 4ae10287..4460d4e6 100644 --- a/lib/ansible/modules/cloud/alicloud/ali_vswitch_info.py +++ b/plugins/modules/ali_vswitch_info.py @@ -76,7 +76,7 @@ - "python >= 3.6" - "footmark >= 1.14.1" extends_documentation_fragment: - - alicloud + - alibaba.alicloud.alicloud ''' EXAMPLES = ''' @@ -175,7 +175,7 @@ ''' from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect +from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, vpc_connect HAS_FOOTMARK = False diff --git a/plugins/tests/__init__.py b/plugins/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/ali_disk_info_test.yml b/plugins/tests/ali_disk_info_test.yml similarity index 97% rename from tests/ali_disk_info_test.yml rename to plugins/tests/ali_disk_info_test.yml index ba59a3f3..4a29b6e0 100644 --- a/tests/ali_disk_info_test.yml +++ b/plugins/tests/ali_disk_info_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_dns_domain_info_test.yml b/plugins/tests/ali_dns_domain_info_test.yml similarity index 91% rename from tests/ali_dns_domain_info_test.yml rename to plugins/tests/ali_dns_domain_info_test.yml index 05e9cdc2..04001054 100644 --- a/tests/ali_dns_domain_info_test.yml +++ b/plugins/tests/ali_dns_domain_info_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - dns diff --git a/tests/ali_dns_domain_test.yml b/plugins/tests/ali_dns_domain_test.yml similarity index 96% rename from tests/ali_dns_domain_test.yml rename to plugins/tests/ali_dns_domain_test.yml index 2ef88caa..e42c329b 100644 --- a/tests/ali_dns_domain_test.yml +++ b/plugins/tests/ali_dns_domain_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - dns_group - dns diff --git a/tests/ali_dns_group_info_test.yml b/plugins/tests/ali_dns_group_info_test.yml similarity index 93% rename from tests/ali_dns_group_info_test.yml rename to plugins/tests/ali_dns_group_info_test.yml index 59a1d3e3..64663bb1 100644 --- a/tests/ali_dns_group_info_test.yml +++ b/plugins/tests/ali_dns_group_info_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - dns_group diff --git a/tests/ali_dns_group_test.yml b/plugins/tests/ali_dns_group_test.yml similarity index 92% rename from tests/ali_dns_group_test.yml rename to plugins/tests/ali_dns_group_test.yml index f4de1ba4..5684d1fa 100644 --- a/tests/ali_dns_group_test.yml +++ b/plugins/tests/ali_dns_group_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - dns - dns_group diff --git a/tests/ali_ecs_tag_test.yml b/plugins/tests/ali_ecs_tag_test.yml similarity index 99% rename from tests/ali_ecs_tag_test.yml rename to plugins/tests/ali_ecs_tag_test.yml index 7ccb13fb..52583cd9 100644 --- a/tests/ali_ecs_tag_test.yml +++ b/plugins/tests/ali_ecs_tag_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_eip_info_test.yml b/plugins/tests/ali_eip_info_test.yml similarity index 93% rename from tests/ali_eip_info_test.yml rename to plugins/tests/ali_eip_info_test.yml index 3b65239a..efdb12ee 100644 --- a/tests/ali_eip_info_test.yml +++ b/plugins/tests/ali_eip_info_test.yml @@ -6,6 +6,8 @@ vars: name: ansible-testacc-ali_eip_facts-module + collections: + - alibaba.alicloud roles: - eip diff --git a/tests/ali_eip_test.yml b/plugins/tests/ali_eip_test.yml similarity index 99% rename from tests/ali_eip_test.yml rename to plugins/tests/ali_eip_test.yml index 1ff4b0dc..856d191b 100644 --- a/tests/ali_eip_test.yml +++ b/plugins/tests/ali_eip_test.yml @@ -7,6 +7,8 @@ allocate_public_ip: False name: ansible-testacc-ali_eip-module + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_eni_info_test.yml b/plugins/tests/ali_eni_info_test.yml similarity index 97% rename from tests/ali_eni_info_test.yml rename to plugins/tests/ali_eni_info_test.yml index b9630035..f5a7fc17 100644 --- a/tests/ali_eni_info_test.yml +++ b/plugins/tests/ali_eni_info_test.yml @@ -6,6 +6,8 @@ vars: name: ansible-testacc-ali_eni_facts-module + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_eni_test.yml b/plugins/tests/ali_eni_test.yml similarity index 99% rename from tests/ali_eni_test.yml rename to plugins/tests/ali_eni_test.yml index 3e4db3d0..f3357119 100644 --- a/tests/ali_eni_test.yml +++ b/plugins/tests/ali_eni_test.yml @@ -6,6 +6,8 @@ vars: name: ansible-testacc-ali_eni-module + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_instance_info_test.yml b/plugins/tests/ali_instance_info_test.yml similarity index 98% rename from tests/ali_instance_info_test.yml rename to plugins/tests/ali_instance_info_test.yml index cb775199..a227942d 100644 --- a/tests/ali_instance_info_test.yml +++ b/plugins/tests/ali_instance_info_test.yml @@ -6,6 +6,8 @@ vars: name: ansible-testacc-ali_instance_facts-module + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_instance_prepaid_test.yml b/plugins/tests/ali_instance_prepaid_test.yml similarity index 99% rename from tests/ali_instance_prepaid_test.yml rename to plugins/tests/ali_instance_prepaid_test.yml index 15dc2a34..67d84e11 100644 --- a/tests/ali_instance_prepaid_test.yml +++ b/plugins/tests/ali_instance_prepaid_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_instance_test.yml b/plugins/tests/ali_instance_test.yml similarity index 99% rename from tests/ali_instance_test.yml rename to plugins/tests/ali_instance_test.yml index 9b747d19..ec2e487c 100644 --- a/tests/ali_instance_test.yml +++ b/plugins/tests/ali_instance_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_market_product_test.yml b/plugins/tests/ali_market_product_test.yml similarity index 97% rename from tests/ali_market_product_test.yml rename to plugins/tests/ali_market_product_test.yml index 020c9c73..3c576196 100644 --- a/tests/ali_market_product_test.yml +++ b/plugins/tests/ali_market_product_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_oos_execution_info_test.yml b/plugins/tests/ali_oos_execution_info_test.yml similarity index 98% rename from tests/ali_oos_execution_info_test.yml rename to plugins/tests/ali_oos_execution_info_test.yml index edc29fff..7ebc4a04 100644 --- a/tests/ali_oos_execution_info_test.yml +++ b/plugins/tests/ali_oos_execution_info_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_oos_execution_test.yml b/plugins/tests/ali_oos_execution_test.yml similarity index 98% rename from tests/ali_oos_execution_test.yml rename to plugins/tests/ali_oos_execution_test.yml index b4d4be11..5bdd1a01 100644 --- a/tests/ali_oos_execution_test.yml +++ b/plugins/tests/ali_oos_execution_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_oos_template_info_test.yml b/plugins/tests/ali_oos_template_info_test.yml similarity index 100% rename from tests/ali_oos_template_info_test.yml rename to plugins/tests/ali_oos_template_info_test.yml diff --git a/tests/ali_oos_template_test.yml b/plugins/tests/ali_oos_template_test.yml similarity index 100% rename from tests/ali_oos_template_test.yml rename to plugins/tests/ali_oos_template_test.yml diff --git a/tests/ali_ram_access_key_info_test.yml b/plugins/tests/ali_ram_access_key_info_test.yml similarity index 100% rename from tests/ali_ram_access_key_info_test.yml rename to plugins/tests/ali_ram_access_key_info_test.yml diff --git a/tests/ali_ram_access_key_test.yml b/plugins/tests/ali_ram_access_key_test.yml similarity index 100% rename from tests/ali_ram_access_key_test.yml rename to plugins/tests/ali_ram_access_key_test.yml diff --git a/tests/ali_ram_group_info_test.yml b/plugins/tests/ali_ram_group_info_test.yml similarity index 100% rename from tests/ali_ram_group_info_test.yml rename to plugins/tests/ali_ram_group_info_test.yml diff --git a/tests/ali_ram_group_test.yml b/plugins/tests/ali_ram_group_test.yml similarity index 100% rename from tests/ali_ram_group_test.yml rename to plugins/tests/ali_ram_group_test.yml diff --git a/tests/ali_ram_login_profile_info_test.yml b/plugins/tests/ali_ram_login_profile_info_test.yml similarity index 100% rename from tests/ali_ram_login_profile_info_test.yml rename to plugins/tests/ali_ram_login_profile_info_test.yml diff --git a/tests/ali_ram_login_profile_test.yml b/plugins/tests/ali_ram_login_profile_test.yml similarity index 100% rename from tests/ali_ram_login_profile_test.yml rename to plugins/tests/ali_ram_login_profile_test.yml diff --git a/tests/ali_ram_policy_info_test.yml b/plugins/tests/ali_ram_policy_info_test.yml similarity index 100% rename from tests/ali_ram_policy_info_test.yml rename to plugins/tests/ali_ram_policy_info_test.yml diff --git a/tests/ali_ram_policy_test.yml b/plugins/tests/ali_ram_policy_test.yml similarity index 100% rename from tests/ali_ram_policy_test.yml rename to plugins/tests/ali_ram_policy_test.yml diff --git a/tests/ali_ram_profile_info_test.yml b/plugins/tests/ali_ram_profile_info_test.yml similarity index 100% rename from tests/ali_ram_profile_info_test.yml rename to plugins/tests/ali_ram_profile_info_test.yml diff --git a/tests/ali_ram_profile_test.yml b/plugins/tests/ali_ram_profile_test.yml similarity index 100% rename from tests/ali_ram_profile_test.yml rename to plugins/tests/ali_ram_profile_test.yml diff --git a/tests/ali_ram_role_info_test.yml b/plugins/tests/ali_ram_role_info_test.yml similarity index 100% rename from tests/ali_ram_role_info_test.yml rename to plugins/tests/ali_ram_role_info_test.yml diff --git a/tests/ali_ram_role_test.yml b/plugins/tests/ali_ram_role_test.yml similarity index 100% rename from tests/ali_ram_role_test.yml rename to plugins/tests/ali_ram_role_test.yml diff --git a/tests/ali_ram_user_info_test.yml b/plugins/tests/ali_ram_user_info_test.yml similarity index 100% rename from tests/ali_ram_user_info_test.yml rename to plugins/tests/ali_ram_user_info_test.yml diff --git a/tests/ali_ram_user_test.yml b/plugins/tests/ali_ram_user_test.yml similarity index 100% rename from tests/ali_ram_user_test.yml rename to plugins/tests/ali_ram_user_test.yml diff --git a/tests/ali_rds_account_info_test.yml b/plugins/tests/ali_rds_account_info_test.yml similarity index 94% rename from tests/ali_rds_account_info_test.yml rename to plugins/tests/ali_rds_account_info_test.yml index 9fbdc43f..d9328223 100644 --- a/tests/ali_rds_account_info_test.yml +++ b/plugins/tests/ali_rds_account_info_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_rds_account_test.yml b/plugins/tests/ali_rds_account_test.yml similarity index 98% rename from tests/ali_rds_account_test.yml rename to plugins/tests/ali_rds_account_test.yml index afa94169..80d3695a 100644 --- a/tests/ali_rds_account_test.yml +++ b/plugins/tests/ali_rds_account_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_rds_backup_info_test.yml b/plugins/tests/ali_rds_backup_info_test.yml similarity index 94% rename from tests/ali_rds_backup_info_test.yml rename to plugins/tests/ali_rds_backup_info_test.yml index fd8620cf..5a04bf5a 100644 --- a/tests/ali_rds_backup_info_test.yml +++ b/plugins/tests/ali_rds_backup_info_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_rds_backup_test.yml b/plugins/tests/ali_rds_backup_test.yml similarity index 94% rename from tests/ali_rds_backup_test.yml rename to plugins/tests/ali_rds_backup_test.yml index d7ffb533..fdc21073 100644 --- a/tests/ali_rds_backup_test.yml +++ b/plugins/tests/ali_rds_backup_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_rds_copy_database_between_instance_test.yml b/plugins/tests/ali_rds_copy_database_between_instance_test.yml similarity index 98% rename from tests/ali_rds_copy_database_between_instance_test.yml rename to plugins/tests/ali_rds_copy_database_between_instance_test.yml index 5c74a714..a1662a81 100644 --- a/tests/ali_rds_copy_database_between_instance_test.yml +++ b/plugins/tests/ali_rds_copy_database_between_instance_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_rds_database_info_test.yml b/plugins/tests/ali_rds_database_info_test.yml similarity index 97% rename from tests/ali_rds_database_info_test.yml rename to plugins/tests/ali_rds_database_info_test.yml index 02b87af2..23b6be39 100644 --- a/tests/ali_rds_database_info_test.yml +++ b/plugins/tests/ali_rds_database_info_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_rds_database_test.yml b/plugins/tests/ali_rds_database_test.yml similarity index 97% rename from tests/ali_rds_database_test.yml rename to plugins/tests/ali_rds_database_test.yml index bdd920b1..9486eac6 100644 --- a/tests/ali_rds_database_test.yml +++ b/plugins/tests/ali_rds_database_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_rds_instance_info_test.yml b/plugins/tests/ali_rds_instance_info_test.yml similarity index 96% rename from tests/ali_rds_instance_info_test.yml rename to plugins/tests/ali_rds_instance_info_test.yml index c0c4d23a..8b490d92 100644 --- a/tests/ali_rds_instance_info_test.yml +++ b/plugins/tests/ali_rds_instance_info_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_rds_instance_test.yml b/plugins/tests/ali_rds_instance_test.yml similarity index 98% rename from tests/ali_rds_instance_test.yml rename to plugins/tests/ali_rds_instance_test.yml index 39488992..714ab36c 100644 --- a/tests/ali_rds_instance_test.yml +++ b/plugins/tests/ali_rds_instance_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_ros_info_test.yml b/plugins/tests/ali_ros_info_test.yml similarity index 100% rename from tests/ali_ros_info_test.yml rename to plugins/tests/ali_ros_info_test.yml diff --git a/tests/ali_ros_test.yml b/plugins/tests/ali_ros_test.yml similarity index 100% rename from tests/ali_ros_test.yml rename to plugins/tests/ali_ros_test.yml diff --git a/tests/ali_route_entry_test.yml b/plugins/tests/ali_route_entry_test.yml similarity index 98% rename from tests/ali_route_entry_test.yml rename to plugins/tests/ali_route_entry_test.yml index 526f9842..0ebca794 100644 --- a/tests/ali_route_entry_test.yml +++ b/plugins/tests/ali_route_entry_test.yml @@ -7,6 +7,8 @@ name: ansible-testacc-ali_vpc-module # availability_zone: cn-hangzhou-b + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_security_group_info_test.yml b/plugins/tests/ali_security_group_info_test.yml similarity index 96% rename from tests/ali_security_group_info_test.yml rename to plugins/tests/ali_security_group_info_test.yml index d0f3b2e4..56171a62 100644 --- a/tests/ali_security_group_info_test.yml +++ b/plugins/tests/ali_security_group_info_test.yml @@ -4,6 +4,8 @@ remote_user: root vars: name: ansible-testacc-ali_security_group_facts-module + collections: + - alibaba.alicloud roles: - vpc - security_group diff --git a/tests/ali_security_group_test.yml b/plugins/tests/ali_security_group_test.yml similarity index 99% rename from tests/ali_security_group_test.yml rename to plugins/tests/ali_security_group_test.yml index 35bd16a7..8095a19b 100644 --- a/tests/ali_security_group_test.yml +++ b/plugins/tests/ali_security_group_test.yml @@ -6,6 +6,8 @@ vars: name: ansible-testacc-ali_security_group-module + collections: + - alibaba.alicloud roles: - vpc - security_group diff --git a/tests/ali_slb_lb_info_test.yml b/plugins/tests/ali_slb_lb_info_test.yml similarity index 96% rename from tests/ali_slb_lb_info_test.yml rename to plugins/tests/ali_slb_lb_info_test.yml index 03f713d3..18663f07 100644 --- a/tests/ali_slb_lb_info_test.yml +++ b/plugins/tests/ali_slb_lb_info_test.yml @@ -6,6 +6,8 @@ vars: name: ansible-testacc-ali_slb_lb_facts + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_slb_lb_test.yml b/plugins/tests/ali_slb_lb_test.yml similarity index 98% rename from tests/ali_slb_lb_test.yml rename to plugins/tests/ali_slb_lb_test.yml index 098f9ebc..a7c0fc7e 100644 --- a/tests/ali_slb_lb_test.yml +++ b/plugins/tests/ali_slb_lb_test.yml @@ -6,6 +6,8 @@ vars: name: ansible-testacc-ali_slb_lb + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_slb_server_test.yml b/plugins/tests/ali_slb_server_test.yml similarity index 98% rename from tests/ali_slb_server_test.yml rename to plugins/tests/ali_slb_server_test.yml index f3164827..e18f4013 100644 --- a/tests/ali_slb_server_test.yml +++ b/plugins/tests/ali_slb_server_test.yml @@ -7,6 +7,8 @@ number_of_instances: 4 name: ansible-testacc-ali_slb_lb + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_slb_tag_test.yml b/plugins/tests/ali_slb_tag_test.yml similarity index 97% rename from tests/ali_slb_tag_test.yml rename to plugins/tests/ali_slb_tag_test.yml index e541c02f..d12118eb 100644 --- a/tests/ali_slb_tag_test.yml +++ b/plugins/tests/ali_slb_tag_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_slb_vsg_info_test.yml b/plugins/tests/ali_slb_vsg_info_test.yml similarity index 98% rename from tests/ali_slb_vsg_info_test.yml rename to plugins/tests/ali_slb_vsg_info_test.yml index e3c788d7..215eb924 100644 --- a/tests/ali_slb_vsg_info_test.yml +++ b/plugins/tests/ali_slb_vsg_info_test.yml @@ -5,6 +5,8 @@ vars: number_of_instances: 2 name: ansible-testacc-ali_slb_vsg_facts-module + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_slb_vsg_test.yml b/plugins/tests/ali_slb_vsg_test.yml similarity index 99% rename from tests/ali_slb_vsg_test.yml rename to plugins/tests/ali_slb_vsg_test.yml index 4272459b..309662f0 100644 --- a/tests/ali_slb_vsg_test.yml +++ b/plugins/tests/ali_slb_vsg_test.yml @@ -5,6 +5,8 @@ vars: number_of_instances: 4 name: ansible-testacc-ali_slb_vsg-module + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_sts_test.yml b/plugins/tests/ali_sts_test.yml similarity index 100% rename from tests/ali_sts_test.yml rename to plugins/tests/ali_sts_test.yml diff --git a/tests/ali_tags_test.yml b/plugins/tests/ali_tags_test.yml similarity index 100% rename from tests/ali_tags_test.yml rename to plugins/tests/ali_tags_test.yml diff --git a/tests/ali_vpc_info_test.yml b/plugins/tests/ali_vpc_info_test.yml similarity index 96% rename from tests/ali_vpc_info_test.yml rename to plugins/tests/ali_vpc_info_test.yml index a595aaaf..8418938e 100644 --- a/tests/ali_vpc_info_test.yml +++ b/plugins/tests/ali_vpc_info_test.yml @@ -6,6 +6,8 @@ vars: name: ansible-testacc-ali_vpc_facts-module + collections: + - alibaba.alicloud roles: - vpc diff --git a/tests/ali_vpc_tag_test.yml b/plugins/tests/ali_vpc_tag_test.yml similarity index 98% rename from tests/ali_vpc_tag_test.yml rename to plugins/tests/ali_vpc_tag_test.yml index 8bedb4ac..18dac2eb 100644 --- a/tests/ali_vpc_tag_test.yml +++ b/plugins/tests/ali_vpc_tag_test.yml @@ -3,6 +3,8 @@ hosts: localhost remote_user: root + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_vpc_test.yml b/plugins/tests/ali_vpc_test.yml similarity index 98% rename from tests/ali_vpc_test.yml rename to plugins/tests/ali_vpc_test.yml index 61059039..580a6d18 100644 --- a/tests/ali_vpc_test.yml +++ b/plugins/tests/ali_vpc_test.yml @@ -5,10 +5,10 @@ vars: name: ansible-testacc-ali_vpc-module - + collections: + - alibaba.alicloud roles: - vpc - tasks: - name: Changed. Create a new vpc with user_cidrs ali_vpc: diff --git a/tests/ali_vswitch_info_test.yml b/plugins/tests/ali_vswitch_info_test.yml similarity index 97% rename from tests/ali_vswitch_info_test.yml rename to plugins/tests/ali_vswitch_info_test.yml index fd5fb558..7502886e 100644 --- a/tests/ali_vswitch_info_test.yml +++ b/plugins/tests/ali_vswitch_info_test.yml @@ -6,6 +6,8 @@ vars: name: ansible-testacc-ali_vswitch_facts-module + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/ali_vswitch_test.yml b/plugins/tests/ali_vswitch_test.yml similarity index 98% rename from tests/ali_vswitch_test.yml rename to plugins/tests/ali_vswitch_test.yml index a0000cb5..d67cc276 100644 --- a/tests/ali_vswitch_test.yml +++ b/plugins/tests/ali_vswitch_test.yml @@ -6,6 +6,8 @@ vars: name: ansible-testacc-ali_vswitch-module + collections: + - alibaba.alicloud roles: - vpc - vswitch diff --git a/tests/destroy.yml b/plugins/tests/destroy.yml similarity index 100% rename from tests/destroy.yml rename to plugins/tests/destroy.yml diff --git a/tests/group_vars/all b/plugins/tests/group_vars/all similarity index 100% rename from tests/group_vars/all rename to plugins/tests/group_vars/all diff --git a/plugins/tests/roles/__init__.py b/plugins/tests/roles/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/roles/disk/tasks/main.yml b/plugins/tests/roles/disk/tasks/main.yml similarity index 93% rename from tests/roles/disk/tasks/main.yml rename to plugins/tests/roles/disk/tasks/main.yml index e5526fc0..a5b1769c 100644 --- a/tests/roles/disk/tasks/main.yml +++ b/plugins/tests/roles/disk/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Create first new disk and attach it to an instance 0 - ali_disk: + alibaba.alicloud.ali_disk: alicloud_zone: '{{ availability_zone }}' disk_name: '{{ disk_name }}-0' disk_category: '{{ disk_category }}' @@ -12,7 +12,7 @@ register: disk_details - name: Create a new disk and attach it to an instance - ali_disk: + alibaba.alicloud.ali_disk: alicloud_zone: '{{ availability_zone }}' disk_name: '{{ disk_name }}-1' disk_category: '{{ disk_category }}' diff --git a/tests/roles/dns/tasks/main.yml b/plugins/tests/roles/dns/tasks/main.yml similarity index 72% rename from tests/roles/dns/tasks/main.yml rename to plugins/tests/roles/dns/tasks/main.yml index b7ad07df..9e955667 100644 --- a/tests/roles/dns/tasks/main.yml +++ b/plugins/tests/roles/dns/tasks/main.yml @@ -1,11 +1,11 @@ --- - name: Create a new domain - ali_dns_domain: + alibaba.alicloud.ali_dns_domain: state: 'present' domain_name: '{{ domain_name }}' remark: '{{ remark }}' - name: Get the existing dns - ali_dns_domain_info: + alibaba.alicloud.ali_dns_domain_info: domain_name: '{{ domain_name }}' register: dns \ No newline at end of file diff --git a/tests/roles/dns_group/tasks/main.yml b/plugins/tests/roles/dns_group/tasks/main.yml similarity index 71% rename from tests/roles/dns_group/tasks/main.yml rename to plugins/tests/roles/dns_group/tasks/main.yml index 04ecdc60..778c4c1a 100644 --- a/tests/roles/dns_group/tasks/main.yml +++ b/plugins/tests/roles/dns_group/tasks/main.yml @@ -1,10 +1,10 @@ --- - name: Changed. Create dns group. - ali_dns_group: + alibaba.alicloud.ali_dns_group: group_name: '{{ group_name }}' register: group - name: Get the existing group - ali_dns_group_info: + alibaba.alicloud.ali_dns_group_info: name_prefix: '{{ group_name }}' register: groups diff --git a/tests/roles/eip/tasks/main.yml b/plugins/tests/roles/eip/tasks/main.yml similarity index 85% rename from tests/roles/eip/tasks/main.yml rename to plugins/tests/roles/eip/tasks/main.yml index 641d7a46..8362d39c 100644 --- a/tests/roles/eip/tasks/main.yml +++ b/plugins/tests/roles/eip/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Create a new alicloud EIP resource - ali_eip: + alibaba.alicloud.ali_eip: internet_charge_type: '{{ internet_charge_type }}' bandwidth: 1 name: '{{ name }}-ali-eip' diff --git a/tests/roles/instance/tasks/main.yml b/plugins/tests/roles/instance/tasks/main.yml similarity index 92% rename from tests/roles/instance/tasks/main.yml rename to plugins/tests/roles/instance/tasks/main.yml index 7d935be2..0dcc51e6 100644 --- a/tests/roles/instance/tasks/main.yml +++ b/plugins/tests/roles/instance/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Get the existing ECS instances - ali_instance_info: + alibaba.alicloud.ali_instance_info: name_prefix: '{{ name }}' filters: vpc_id: '{{ vpcs.vpcs.0.id }}' @@ -9,7 +9,7 @@ register: instances - name: Creating an ECS instance - ali_instance: + alibaba.alicloud.ali_instance: image: '{{ image_id }}' type: '{{ instance_type }}' instance_name: '{{ name }}' @@ -40,7 +40,7 @@ when: not instances.instances - name: Get the existing ECS instances - ali_instance_info: + alibaba.alicloud.ali_instance_info: name_prefix: '{{ name }}' filters: vpc_id: '{{ vpcs.vpcs.0.id }}' diff --git a/tests/roles/network_interface/tasks/main.yml b/plugins/tests/roles/network_interface/tasks/main.yml similarity index 86% rename from tests/roles/network_interface/tasks/main.yml rename to plugins/tests/roles/network_interface/tasks/main.yml index ce917381..ed557f49 100644 --- a/tests/roles/network_interface/tasks/main.yml +++ b/plugins/tests/roles/network_interface/tasks/main.yml @@ -1,13 +1,13 @@ --- - name: Get the existing network interfaces - ali_eni_info: + alibaba.alicloud.ali_eni_info: name_prefix: '{{name}}' filters: vpc_id: '{{ vpcs.vpcs.0.id }}' register: enis - name: Creating a network interface - ali_eni: + alibaba.alicloud.ali_eni: vswitch_id: '{{ vswitches.vswitches.0.id }}' security_groups: ['{{ sgs.groups.0.id }}'] name: '{{ name }}' @@ -16,7 +16,7 @@ when: not enis.interfaces - name: Creating a network interface with private ip - ali_eni: + alibaba.alicloud.ali_eni: vswitch_id: '{{ vswitches.vswitches.0.id }}' security_groups: ['{{ sgs.groups.0.id }}'] name: '{{ name }}-ip' @@ -26,7 +26,7 @@ when: not enis.interfaces - name: Get the existing network interfaces - ali_eni_info: + alibaba.alicloud.ali_eni_info: name_prefix: '{{name}}' filters: vpc_id: '{{ vpcs.vpcs.0.id }}' diff --git a/tests/roles/rds/tasks/main.yml b/plugins/tests/roles/rds/tasks/main.yml similarity index 85% rename from tests/roles/rds/tasks/main.yml rename to plugins/tests/roles/rds/tasks/main.yml index 75e5e97a..5874364e 100644 --- a/tests/roles/rds/tasks/main.yml +++ b/plugins/tests/roles/rds/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Changed. Create a new RDS Instance - ali_rds_instance: + alibaba.alicloud.ali_rds_instance: state: present engine: MySQL engine_version: 5.6 @@ -14,6 +14,6 @@ register: rds - name: Get the existing rds - ali_rds_instance_info: + alibaba.alicloud.ali_rds_instance_info: db_instance_ids: ['{{ rds.instances.id }}'] register: rds diff --git a/tests/roles/security_group/tasks/main.yml b/plugins/tests/roles/security_group/tasks/main.yml similarity index 82% rename from tests/roles/security_group/tasks/main.yml rename to plugins/tests/roles/security_group/tasks/main.yml index 1843da55..fcb1102e 100644 --- a/tests/roles/security_group/tasks/main.yml +++ b/plugins/tests/roles/security_group/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Create a VPC security group - ali_security_group: + alibaba.alicloud.ali_security_group: state: 'present' name: '{{ name }}' description: '{{ group_description }}' @@ -10,7 +10,7 @@ register: group - name: Get the existing groups - ali_security_group_info: + alibaba.alicloud.ali_security_group_info: name_prefix: '{{ name }}' filters: vpc_id: '{{vpcs.vpcs.0.id}}' diff --git a/tests/roles/slb/tasks/main.yml b/plugins/tests/roles/slb/tasks/main.yml similarity index 87% rename from tests/roles/slb/tasks/main.yml rename to plugins/tests/roles/slb/tasks/main.yml index 69b3bf01..b9de645f 100644 --- a/tests/roles/slb/tasks/main.yml +++ b/plugins/tests/roles/slb/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Creating a public SLB instance - ali_slb_lb: + alibaba.alicloud.ali_slb_lb: name: '{{ name }}-public' internet_charge_type: '{{ internet_charge_type }}' is_internet: True @@ -9,7 +9,7 @@ register: slbpub - name: Creating a private SLB instance - ali_slb_lb: + alibaba.alicloud.ali_slb_lb: name: '{{ name }}-private' internet_charge_type: '{{ internet_charge_type }}' spec: slb.s1.small diff --git a/tests/roles/vpc/tasks/main.yml b/plugins/tests/roles/vpc/tasks/main.yml similarity index 80% rename from tests/roles/vpc/tasks/main.yml rename to plugins/tests/roles/vpc/tasks/main.yml index 67ac4db4..98d40dd0 100644 --- a/tests/roles/vpc/tasks/main.yml +++ b/plugins/tests/roles/vpc/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Create a new alicloud VPC resource - ali_vpc: + alibaba.alicloud.ali_vpc: state: 'present' cidr_block: '{{ vpc_cidr }}' vpc_name: '{{ name }}' @@ -8,6 +8,6 @@ register: vpc - name: Get the existing vpc - ali_vpc_info: + alibaba.alicloud.ali_vpc_info: name_prefix: '{{name}}' register: vpcs \ No newline at end of file diff --git a/tests/roles/vswitch/tasks/main.yml b/plugins/tests/roles/vswitch/tasks/main.yml similarity index 84% rename from tests/roles/vswitch/tasks/main.yml rename to plugins/tests/roles/vswitch/tasks/main.yml index ada06c04..ca703c0c 100644 --- a/tests/roles/vswitch/tasks/main.yml +++ b/plugins/tests/roles/vswitch/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Create a new alicloud VSwitch resource - ali_vswitch: + alibaba.alicloud.ali_vswitch: alicloud_zone: '{{ availability_zone }}' cidr_block: '{{ vswitch_cidr }}' vswitch_name: '{{ name }}' @@ -9,7 +9,7 @@ register: vswitch - name: Get the existing vswitch - ali_vswitch_info: + alibaba.alicloud.ali_vswitch_info: name_prefix: '{{ name }}' filters: vpc_id: '{{vpc.vpc.id}}' diff --git a/roles/ansible.cfg b/roles/ansible.cfg deleted file mode 100644 index 17d24490..00000000 --- a/roles/ansible.cfg +++ /dev/null @@ -1,461 +0,0 @@ -# config file for ansible -- https://ansible.com/ -# =============================================== - -# nearly all parameters can be overridden in ansible-playbook -# or with command line flags. ansible will read ANSIBLE_CONFIG, -# ansible.cfg in the current working directory, .ansible.cfg in -# the home directory or /etc/ansible/ansible.cfg, whichever it -# finds first - -[defaults] - -# some basic default values... - -#inventory = /etc/ansible/hosts -#library = /usr/share/my_modules/ -#library = /home/ubuntu/work/ansible-provider/lib/ansible/modules/cloud/alicloud/ -#module_utils = /home/ubuntu/work/ansible-provider/lib/ansible/module_utils -#remote_tmp = ~/.ansible/tmp -#local_tmp = ~/.ansible/tmp -#forks = 5 -#poll_interval = 15 -#sudo_user = root -#ask_sudo_pass = True -#ask_pass = True -#transport = smart -#remote_port = 22 -#module_lang = C -#module_set_locale = False - -# plays will gather facts by default, which contain information about -# the remote system. -# -# smart - gather by default, but don't regather if already gathered -# implicit - gather by default, turn off with gather_facts: False -# explicit - do not gather by default, must say gather_facts: True -#gathering = implicit - -# This only affects the gathering done by a play's gather_facts directive, -# by default gathering retrieves all facts subsets -# all - gather all subsets -# network - gather min and network facts -# hardware - gather hardware facts (longest facts to retrieve) -# virtual - gather min and virtual facts -# facter - import facts from facter -# ohai - import facts from ohai -# You can combine them using comma (ex: network,virtual) -# You can negate them using ! (ex: !hardware,!facter,!ohai) -# A minimal set of facts is always gathered. -#gather_subset = all - -# some hardware related facts are collected -# with a maximum timeout of 10 seconds. This -# option lets you increase or decrease that -# timeout to something more suitable for the -# environment. -# gather_timeout = 10 - -# additional paths to search for roles in, colon separated -#roles_path = /etc/ansible/roles - -# uncomment this to disable SSH key host checking -#host_key_checking = False - -# change the default callback, you can only have one 'stdout' type enabled at a time. -#stdout_callback = skippy - - -## Ansible ships with some plugins that require whitelisting, -## this is done to avoid running all of a type by default. -## These setting lists those that you want enabled for your system. -## Custom plugins should not need this unless plugin author specifies it. - -# enable callback plugins, they can output to stdout but cannot be 'stdout' type. -#callback_whitelist = timer, mail - -# enable inventory plugins, default: 'host_list', 'script', 'ini', 'yaml' -#inventory_enabled = host_list, aws, openstack, docker - -# Determine whether includes in tasks and handlers are "static" by -# default. As of 2.0, includes are dynamic by default. Setting these -# values to True will make includes behave more like they did in the -# 1.x versions. -#task_includes_static = True -#handler_includes_static = True - -# Controls if a missing handler for a notification event is an error or a warning -# error_on_missing_handler = True - -# change this for alternative sudo implementations -#sudo_exe = sudo - -# What flags to pass to sudo -# WARNING: leaving out the defaults might create unexpected behaviours -#sudo_flags = -H -S -n - -# SSH timeout -#timeout = 10 - -# default user to use for playbooks if user is not specified -# (/usr/bin/ansible will use current user as default) -#remote_user = root - -# logging is off by default unless this path is defined -# if so defined, consider logrotate -#log_path = ./ansible.log - -# default module name for /usr/bin/ansible -#module_name = command - -# use this shell for commands executed under sudo -# you may need to change this to bin/bash in rare instances -# if sudo is constrained -#executable = /bin/sh - -# if inventory variables overlap, does the higher precedence one win -# or are hash values merged together? The default is 'replace' but -# this can also be set to 'merge'. -#hash_behaviour = replace - -# by default, variables from roles will be visible in the global variable -# scope. To prevent this, the following option can be enabled, and only -# tasks and handlers within the role will see the variables there -#private_role_vars = yes - -# list any Jinja2 extensions to enable here: -#jinja2_extensions = jinja2.ext.do,jinja2.ext.i18n - -# if set, always use this private key file for authentication, same as -# if passing --private-key to ansible or ansible-playbook -#private_key_file = /path/to/file - -# If set, configures the path to the Vault password file as an alternative to -# specifying --vault-password-file on the command line. -#vault_password_file = /path/to/vault_password_file - -# format of string {{ ansible_managed }} available within Jinja2 -# templates indicates to users editing templates files will be replaced. -# replacing {file}, {host} and {uid} and strftime codes with proper values. -#ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host} -# {file}, {host}, {uid}, and the timestamp can all interfere with idempotence -# in some situations so the default is a static string: -#ansible_managed = Ansible managed - -# by default, ansible-playbook will display "Skipping [host]" if it determines a task -# should not be run on a host. Set this to "False" if you don't want to see these "Skipping" -# messages. NOTE: the task header will still be shown regardless of whether or not the -# task is skipped. -#display_skipped_hosts = True - -# by default, if a task in a playbook does not include a name: field then -# ansible-playbook will construct a header that includes the task's action but -# not the task's args. This is a security feature because ansible cannot know -# if the *module* considers an argument to be no_log at the time that the -# header is printed. If your environment doesn't have a problem securing -# stdout from ansible-playbook (or you have manually specified no_log in your -# playbook on all of the tasks where you have secret information) then you can -# safely set this to True to get more informative messages. -#display_args_to_stdout = False - -# by default (as of 1.3), Ansible will raise errors when attempting to dereference -# Jinja2 variables that are not set in templates or action lines. Uncomment this line -# to revert the behavior to pre-1.3. -#error_on_undefined_vars = False - -# by default (as of 1.6), Ansible may display warnings based on the configuration of the -# system running ansible itself. This may include warnings about 3rd party packages or -# other conditions that should be resolved if possible. -# to disable these warnings, set the following value to False: -#system_warnings = True - -# by default (as of 1.4), Ansible may display deprecation warnings for language -# features that should no longer be used and will be removed in future versions. -# to disable these warnings, set the following value to False: -#deprecation_warnings = True - -# (as of 1.8), Ansible can optionally warn when usage of the shell and -# command module appear to be simplified by using a default Ansible module -# instead. These warnings can be silenced by adjusting the following -# setting or adding warn=yes or warn=no to the end of the command line -# parameter string. This will for example suggest using the git module -# instead of shelling out to the git command. -# command_warnings = False - - -# set plugin path directories here, separate with colons -#action_plugins = /usr/share/ansible/plugins/action -#cache_plugins = /usr/share/ansible/plugins/cache -#callback_plugins = /usr/share/ansible/plugins/callback -#connection_plugins = /usr/share/ansible/plugins/connection -#lookup_plugins = /usr/share/ansible/plugins/lookup -#inventory_plugins = /usr/share/ansible/plugins/inventory -#vars_plugins = /usr/share/ansible/plugins/vars -#filter_plugins = /usr/share/ansible/plugins/filter -#test_plugins = /usr/share/ansible/plugins/test -#terminal_plugins = /usr/share/ansible/plugins/terminal -#strategy_plugins = /usr/share/ansible/plugins/strategy - - -# by default, ansible will use the 'linear' strategy but you may want to try -# another one -#strategy = free - -# by default callbacks are not loaded for /bin/ansible, enable this if you -# want, for example, a notification or logging callback to also apply to -# /bin/ansible runs -#bin_ansible_callbacks = False - - -# don't like cows? that's unfortunate. -# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1 -#nocows = 1 - -# set which cowsay stencil you'd like to use by default. When set to 'random', -# a random stencil will be selected for each task. The selection will be filtered -# against the `cow_whitelist` option below. -#cow_selection = default -#cow_selection = random - -# when using the 'random' option for cowsay, stencils will be restricted to this list. -# it should be formatted as a comma-separated list with no spaces between names. -# NOTE: line continuations here are for formatting purposes only, as the INI parser -# in python does not support them. -#cow_whitelist=bud-frogs,bunny,cheese,daemon,default,dragon,elephant-in-snake,elephant,eyes,\ -# hellokitty,kitty,luke-koala,meow,milk,moofasa,moose,ren,sheep,small,stegosaurus,\ -# stimpy,supermilker,three-eyes,turkey,turtle,tux,udder,vader-koala,vader,www - -# don't like colors either? -# set to 1 if you don't want colors, or export ANSIBLE_NOCOLOR=1 -#nocolor = 1 - -# if set to a persistent type (not 'memory', for example 'redis') fact values -# from previous runs in Ansible will be stored. This may be useful when -# wanting to use, for example, IP information from one group of servers -# without having to talk to them in the same playbook run to get their -# current IP information. -#fact_caching = memory - - -# retry files -# When a playbook fails by default a .retry file will be created in ~/ -# You can disable this feature by setting retry_files_enabled to False -# and you can change the location of the files by setting retry_files_save_path - -#retry_files_enabled = False -#retry_files_save_path = ~/.ansible-retry - -# squash actions -# Ansible can optimise actions that call modules with list parameters -# when looping. Instead of calling the module once per with_ item, the -# module is called once with all items at once. Currently this only works -# under limited circumstances, and only with parameters named 'name'. -#squash_actions = apk,apt,dnf,homebrew,pacman,pkgng,yum,zypper - -# prevents logging of task data, off by default -#no_log = False - -# prevents logging of tasks, but only on the targets, data is still logged on the master/controller -#no_target_syslog = False - -# controls whether Ansible will raise an error or warning if a task has no -# choice but to create world readable temporary files to execute a module on -# the remote machine. This option is False by default for security. Users may -# turn this on to have behaviour more like Ansible prior to 2.1.x. See -# https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user -# for more secure ways to fix this than enabling this option. -#allow_world_readable_tmpfiles = False - -# controls the compression level of variables sent to -# worker processes. At the default of 0, no compression -# is used. This value must be an integer from 0 to 9. -#var_compression_level = 9 - -# controls what compression method is used for new-style ansible modules when -# they are sent to the remote system. The compression types depend on having -# support compiled into both the controller's python and the client's python. -# The names should match with the python Zipfile compression types: -# * ZIP_STORED (no compression. available everywhere) -# * ZIP_DEFLATED (uses zlib, the default) -# These values may be set per host via the ansible_module_compression inventory -# variable -#module_compression = 'ZIP_DEFLATED' - -# This controls the cutoff point (in bytes) on --diff for files -# set to 0 for unlimited (RAM may suffer!). -#max_diff_size = 1048576 - -# This controls how ansible handles multiple --tags and --skip-tags arguments -# on the CLI. If this is True then multiple arguments are merged together. If -# it is False, then the last specified argument is used and the others are ignored. -# This option will be removed in 2.8. -#merge_multiple_cli_flags = True - -# Controls showing custom stats at the end, off by default -#show_custom_stats = True - -# Controls which files to ignore when using a directory as inventory with -# possibly multiple sources (both static and dynamic) -#inventory_ignore_extensions = ~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo - -# This family of modules use an alternative execution path optimized for network appliances -# only update this setting if you know how this works, otherwise it can break module execution -#network_group_modules=['eos', 'nxos', 'ios', 'iosxr', 'junos', 'vyos'] - -# This keeps facts from polluting the main namespace as variables. -# Setting to True keeps them under the ansible_facts namespace, the default is False -#restrict_facts_namespace: True - -# When enabled, this option allows lookups (via variables like {{lookup('foo')}} or when used as -# a loop with `with_foo`) to return data that is not marked "unsafe". This means the data may contain -# jinja2 templating language which will be run through the templating engine. -# ENABLING THIS COULD BE A SECURITY RISK -#allow_unsafe_lookups = False - -[privilege_escalation] -#become=True -#become_method=sudo -#become_user=root -#become_ask_pass=False - -[paramiko_connection] - -# uncomment this line to cause the paramiko connection plugin to not record new host -# keys encountered. Increases performance on new host additions. Setting works independently of the -# host key checking setting above. -#record_host_keys=False - -# by default, Ansible requests a pseudo-terminal for commands executed under sudo. Uncomment this -# line to disable this behaviour. -#pty=False - -# paramiko will default to looking for SSH keys initially when trying to -# authenticate to remote devices. This is a problem for some network devices -# that close the connection after a key failure. Uncomment this line to -# disable the Paramiko look for keys function -#look_for_keys = False - -# When using persistent connections with Paramiko, the connection runs in a -# background process. If the host doesn't already have a valid SSH key, by -# default Ansible will prompt to add the host key. This will cause connections -# running in background processes to fail. Uncomment this line to have -# Paramiko automatically add host keys. -#host_key_auto_add = True - -[ssh_connection] - -# ssh arguments to use -# Leaving off ControlPersist will result in poor performance, so use -# paramiko on older platforms rather than removing it, -C controls compression use -#ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s - -# The base directory for the ControlPath sockets. -# This is the "%(directory)s" in the control_path option -# -# Example: -# control_path_dir = /tmp/.ansible/cp -#control_path_dir = ~/.ansible/cp - -# The path to use for the ControlPath sockets. This defaults to a hashed string of the hostname, -# port and username (empty string in the config). The hash mitigates a common problem users -# found with long hostames and the conventional %(directory)s/ansible-ssh-%%h-%%p-%%r format. -# In those cases, a "too long for Unix domain socket" ssh error would occur. -# -# Example: -# control_path = %(directory)s/%%h-%%r -#control_path = - -# Enabling pipelining reduces the number of SSH operations required to -# execute a module on the remote server. This can result in a significant -# performance improvement when enabled, however when using "sudo:" you must -# first disable 'requiretty' in /etc/sudoers -# -# By default, this option is disabled to preserve compatibility with -# sudoers configurations that have requiretty (the default on many distros). -# -#pipelining = False - -# Control the mechanism for transferring files (old) -# * smart = try sftp and then try scp [default] -# * True = use scp only -# * False = use sftp only -#scp_if_ssh = smart - -# Control the mechanism for transferring files (new) -# If set, this will override the scp_if_ssh option -# * sftp = use sftp to transfer files -# * scp = use scp to transfer files -# * piped = use 'dd' over SSH to transfer files -# * smart = try sftp, scp, and piped, in that order [default] -#transfer_method = smart - -# if False, sftp will not use batch mode to transfer files. This may cause some -# types of file transfer failures impossible to catch however, and should -# only be disabled if your sftp version has problems with batch mode -#sftp_batch_mode = False - -[persistent_connection] - -# Configures the persistent connection timeout value in seconds. This value is -# how long the persistent connection will remain idle before it is destroyed. -# If the connection doesn't receive a request before the timeout value -# expires, the connection is shutdown. The default value is 30 seconds. -#connect_timeout = 30 - -# Configures the persistent connection retries. This value configures the -# number of attempts the ansible-connection will make when trying to connect -# to the local domain socket. The default value is 30. -#connect_retries = 30 - -# Configures the amount of time in seconds to wait between connection attempts -# to the local unix domain socket. This value works in conjunction with the -# connect_retries value to define how long to try to connect to the local -# domain socket when setting up a persistent connection. The default value is -# 1 second. -#connect_interval = 1 - -[accelerate] -#accelerate_port = 5099 -#accelerate_timeout = 30 -#accelerate_connect_timeout = 5.0 - -# The daemon timeout is measured in minutes. This time is measured -# from the last activity to the accelerate daemon. -#accelerate_daemon_timeout = 30 - -# If set to yes, accelerate_multi_key will allow multiple -# private keys to be uploaded to it, though each user must -# have access to the system via SSH to add a new key. The default -# is "no". -#accelerate_multi_key = yes - -[selinux] -# file systems that require special treatment when dealing with security context -# the default behaviour that copies the existing context or uses the user default -# needs to be changed to use the file system dependent context. -#special_context_filesystems=nfs,vboxsf,fuse,ramfs,9p - -# Set this to yes to allow libvirt_lxc connections to work without SELinux. -#libvirt_lxc_noseclabel = yes - -[colors] -#highlight = white -#verbose = blue -#warn = bright purple -#error = red -#debug = dark gray -#deprecate = purple -#skip = cyan -#unreachable = red -#ok = green -#changed = yellow -#diff_add = green -#diff_remove = red -#diff_lines = cyan - - -[diff] -# Always print diff when running ( same as always running with -D/--diff ) -# always = no - -# Set how many context lines to show in diff -# context = 3 diff --git a/roles/hosts b/roles/hosts deleted file mode 100644 index d18580b3..00000000 --- a/roles/hosts +++ /dev/null @@ -1 +0,0 @@ -localhost \ No newline at end of file diff --git a/roles/test_ecs.yml b/roles/test_ecs.yml deleted file mode 100644 index 5d1e31b2..00000000 --- a/roles/test_ecs.yml +++ /dev/null @@ -1,242 +0,0 @@ -# This Playbook contains test scenario for instance in classic network type -# Playbook created by : Guimin He - -- name: Testing Classic network type scenarions - hosts: localhost - connection: local - vars: - # general - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-a - # create instance - image: centos_6_8_64_40G_base_20170222.vhd - type: ecs.n4.small - instance_name: travis-ansible-instance - description: travis-ansible-instance - host_name: myhost - password: pass@123 - count: 1 - allocate_public_ip: True - - internet_charge_type: PayByBandwidth - max_bandwidth_in: 200 - max_bandwidth_out: 10 - - instance_tags: - - tag_key: create_test_1 - tag_value: '0.01' - - tag_key: create_test_2 - tag_value: '0.02' - instance_ids: ["i-2zefjivpiydsav3s8krg"] - # disk interface - disk_name: travis-ansible-instance - disk_category: cloud_efficiency - size: 40 - disk_tags: - - tag_key: create_test_1 - tag_value: '0.01' - - tag_key: create_test_2 - tag_value: '0.02' - device: /dev/xvdb - - # User defined image - image_name: travis-ansible-instance - image_version: 1 - images_tags: - - tag_key: create_test_1 - tag_value: '0.01' - - tag_key: create_test_2 - tag_value: '0.02' - wait: yes - - # Security Group - sg_name: travis-ansible-instance - inboundRules: - - proto: tcp - port_range: 22/22 - cidr_ip: 0.0.0.0/0 - priority: 1 - - - proto: tcp - port_range: 80/80 - cidr_ip: 0.0.0.0/0 - priority: 1 - - - proto: udp - port_range: 10988/10989 - cidr_ip: 47.89.23.33/32 - priority: 2 - - outboundRules: - - proto: tcp - port_range: 80/80 - cidr_ip: 192.168.0.54/32 - priority: 1 - - - proto: tcp - port_range: 8080/8085 - cidr_ip: 47.89.23.33/32 - priority: 1 - - - proto: udp - port_range: 10989/10997 - cidr_ip: 47.89.23.33/32 - priority: 2 - - tasks: - - name: Creating an ECS instance - ali_instance: - alicloud_region: '{{ alicloud_region }}' - alicloud_zone: '{{ alicloud_zone }}' - image: '{{ image }}' - type: '{{ type }}' - instance_name: '{{ instance_name }}' - description: '{{ description }}' - host_name: '{{ host_name }}' - password: '{{ password }}' -# group_id: 'sg-2zegcq33l0yz9sknp08o' - count: '{{ count }}' - allocate_public_ip: '{{ allocate_public_ip }}' - internet_charge_type: '{{ internet_charge_type }}' - max_bandwidth_in: '{{ max_bandwidth_in }}' - max_bandwidth_out: '{{ max_bandwidth_out }}' - instance_tags: '{{ instance_tags }}' - register: createinstanceresult - - debug: var=createinstanceresult - - - name: Modifying instance attribute - ali_instance: - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ createinstanceresult["instance_ids"] }}' - password: 'Changed123' - host_name: 'mychangedhostname' - register: modifyinstanceresult - - debug: var=modifyinstanceresult -### - - name: Creating disk - ali_disk: - alicloud_region: '{{ alicloud_region }}' - alicloud_zone: '{{ alicloud_zone }}' - disk_name: '{{ disk_name }}' - disk_category: '{{ disk_category }}' - description: '{{ description }}' - size: '{{ size }}' - disk_tags: '{{ disk_tags }}' - register: creatediskresult - - debug: var=creatediskresult - - - name: Attaching disk - ali_disk: - alicloud_region: '{{ alicloud_region }}' - instance_id: '{{ createinstanceresult["instance_ids"][0] }}' -# instance_id: 'i-2ze28xi2fcstau0axqag' - disk_id: '{{ creatediskresult.disk_id }}' -# disk_id: 'd-2ze2no3y81rlqszny17w' - delete_with_instance: true - register: attachingdiskresult - - debug: var=attachingdiskresult - - - name: Detaching disk - ali_disk: - alicloud_region: '{{ alicloud_region }}' - disk_id: '{{ creatediskresult.disk_id }}' - register: detachingdiskresult - - debug: var=detachingdiskresult - - - name: Deleting disk - ali_disk: - alicloud_region: '{{ alicloud_region }}' - disk_id: '{{ creatediskresult.disk_id }}' - state: absent - register: deletingdiskresult - - debug: var=deletingdiskresult - - - name: Creating security group - ali_security_group: - alicloud_region: '{{ alicloud_region }}' - name: '{{ sg_name }}' - description: '{{description}}' -# vpc_id: vpc-2zeigz3lbz2u27gnpbaap -# group_id: sg-2ze9hst5wjxlrgecq4og - rules: '{{ inboundRules }}' - rules_egress: '{{ outboundRules }}' - register: createsgeresult - - debug: var=createsgeresult -# - - name: Quering security group - alicloud_security_group: - alicloud_region: '{{ alicloud_region }}' -# group_id: 'sg-2zed4uaa7mzgk7yxahje' - group_id: '{{ createsgeresult.group_id }}' - state: list - register: quetysgeresult - - debug: var=quetysgeresult -# - - name: Adding ecs instance to security group - ali_instance: - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ createsgeresult.group_id }}' -# group_id: 'sg-2ze4xsw00gvnwihb7mcw' - instance_ids: '{{ createinstanceresult["instance_ids"] }}' -# instance_ids: '{{ instance_ids }}' - sg_action: join - register: joiningsgeresult - - debug: var=joiningsgeresult - - - name: Removing ecs instance from security group - ali_instance: - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ createsgeresult.group_id }}' -# group_id: 'sg-2ze4xsw00gvnwihb7mcw' - instance_ids: '{{ createinstanceresult["instance_ids"] }}' -# instance_ids: '{{ instance_ids }}' - sg_action: leave - register: leavingsgeresult - - debug: var=leavingsgeresult - - - name: Deleting security group - ali_security_group: - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ createsgeresult.group_id }}' -# group_id: 'sg-2ze4xsw00gvnwihb7mcw' - state: absent - register: deletesggeresult - - debug: var=deletesggeresult - - - name: Restarting ECS instance - ali_instance: - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ createinstanceresult["instance_ids"] }}' - state: 'restarted' - register: restartresult - - debug: var=restartresult - - - name: Find all instances in the specified region and instance_ids - ali_instance_facts: - alicloud_region: '{{ alicloud_region }}' - alicloud_ids: '{{ createinstanceresult["instance_ids"] }}' - register: all_instances - - - name: Find all disks in the specified region - ali_disk_facts: - alicloud_zone: "{{ alicloud_zone }}" - alicloud_region: "{{ alicloud_region }}" - register: all_disks - - - name: Find all instance types based on the specified zone and families - ali_instance_type_facts: - alicloud_region: "{{ alicloud_region }}" - alicloud_zone: "{{ alicloud_zone }}" - instance_type_families: - - "ecs.gn5" - - "ecs.m1" - - - name: Terminating ECS instance - ali_instance: - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ createinstanceresult["instance_ids"] }}' - force: True - state: 'absent' - register: deleteresult - - debug: var=deleteresult - diff --git a/roles/test_eni.yml b/roles/test_eni.yml deleted file mode 100644 index c0633560..00000000 --- a/roles/test_eni.yml +++ /dev/null @@ -1,215 +0,0 @@ -# This Playbook contains test scenario for instance in classic network type -# Playbook created by : Guimin He - -- name: Testing network interface scenarions - hosts: localhost - connection: local - vars: - # general - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-a - name: ansible-test-for-eni - description: ansible test for network interface - vpc_cidr: 10.0.0.0/8 - vsw_cidr: 10.0.13.0/24 - # create instance - image: centos_6_8_64_40G_base_20170222.vhd - type: ecs.sn1ne.xlarge - password: Test12345 - count: 1 - allocate_public_ip: True - internet_charge_type: PayByBandwidth - max_bandwidth_out: 10 - - eni_ip: 10.0.13.10 - inboundRules: - - proto: tcp - port_range: 22/22 - cidr_ip: 0.0.0.0/0 - priority: 1 - - - proto: tcp - port_range: 80/80 - cidr_ip: 0.0.0.0/0 - priority: 1 - - - proto: udp - port_range: 10988/10989 - cidr_ip: 47.89.23.33/32 - priority: 2 - - outboundRules: - - proto: tcp - port_range: 80/80 - cidr_ip: 192.168.0.54/32 - priority: 1 - - - proto: tcp - port_range: 8080/8085 - cidr_ip: 47.89.23.33/32 - priority: 1 - - - proto: udp - port_range: 10989/10997 - cidr_ip: 47.89.23.33/32 - priority: 2 - - tasks: - - name: get all enis - ali_eni_facts: - region: '{{alicloud_region}}' - eni_ids: - - eni-2ze70o39tdx2r0o2834h - filters: - NetworkInterfaceName: '{{name}}' - - - name: get all vpcs - ali_vpc_facts: - region: '{{alicloud_region}}' - vpc_name: '{{name}}' - register: vpcs - - - name: Create a vpc - ali_vpc: - region: '{{alicloud_region}}' - name: '{{name}}' - cidr_block: '{{vpc_cidr}}' - when: not vpcs.vpcs - register: vpc - - - name: modify a vpc - ali_vpc: - region: '{{alicloud_region}}' - vpc_id: '{{vpcs.vpcs.0.id}}' - name: '{{name}}' - cidr_block: '{{vpc_cidr}}' - when: vpcs.vpcs - register: vpc - - - name: Create a vswitch - ali_vswitch: - region: '{{alicloud_region}}' - availability_zone: '{{alicloud_zone}}' - name: '{{name}}' - cidr_block: '{{vsw_cidr}}' - vpc_id: '{{vpc.vpc.id}}' - when: vpc.vpc - register: vsw - - - name: get existing groups - ali_security_group_facts: - region: '{{alicloud_region}}' - group_name: '{{ name }}' - filters: - vpc_id: '{{vpc.vpc.id}}' - when: vpc.vpc - register: sgs - - - name: Creating security group - ali_security_group: - region: '{{alicloud_region}}' - name: '{{name}}' - description: '{{description}}' - vpc_id: '{{vpc.vpc.vpc_id}}' - rules: '{{ inboundRules }}' - rules_egress: '{{ outboundRules }}' - when: not sgs.groups - register: sg - - - name: get existing group - ali_security_group: - region: '{{alicloud_region}}' - group_id: '{{sgs.groups.0.id}}' - when: sgs.groups - register: sg - - - name: Creating an ECS instance - ali_instance: - region: '{{alicloud_region}}' - image: '{{image}}' - type: '{{type}}' - instance_name: '{{name}}' - description: '{{description}}' - vswitch_id: '{{vsw.vswitch.id}}' - security_groups: - - '{{sg.group.id}}' - register: instance - - - name: Creating an ENI - ali_eni: - region: '{{alicloud_region}}' - vswitch_id: '{{vsw.vswitch.id}}' - security_groups: - - '{{sg.group.id}}' - name: '{{name}}' - description: '{{description}}' - private_ip_address: '{{eni_ip}}' - register: eni - - - name: Attaching eni - ali_eni: - region: '{{alicloud_region}}' - eni_id: '{{eni.interface.id}}' - instance_id: '{{instance.ids[0]}}' - attached: True - - - name: Detaching eni - ali_eni: - region: '{{alicloud_region}}' - vswitch_id: '{{vsw.vswitch.id}}' - private_ip_address: '{{eni_ip}}' - instance_id: '{{instance.ids[0]}}' - attached: False - - - name: Creating another security group - ali_security_group: - region: '{{alicloud_region}}' - name: '{{name}}-2' - description: '{{description}}' - vpc_id: '{{vpc.vpc.id}}' - register: sg2 - - - name: Modify eni - ali_eni: - region: '{{alicloud_region}}' - vswitch_id: '{{vsw.vswitch.id}}' - private_ip_address: '{{eni_ip}}' - name: '{{name}}' - security_groups: - - '{{sg.group.id}}' - - '{{sg2.group.id}}' - - - name: Delete eni - ali_eni: - region: '{{alicloud_region}}' - vswitch_id: '{{vsw.vswitch.id}}' - private_ip_address: '{{eni_ip}}' - state: absent - - - name: Terminating ECS instance - ali_instance: - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance.ids }}' - force: True - state: 'absent' - - - name: Deleting security group - ali_security_group: - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ item }}' - state: absent - with_items: - - '{{ sg.group.id }}' - - '{{ sg2.group.id }}' - - - name: Deleting vswitch - ali_vswitch: - alicloud_region: '{{ alicloud_region }}' - vswitch_id: '{{ vsw.vswitch.id }}' - state: absent - - - name: Deleting vpc - ali_vpc: - alicloud_region: '{{ alicloud_region }}' - vpc_id: '{{ vpc.vpc.id }}' - state: absent diff --git a/roles/test_ess.yml b/roles/test_ess.yml deleted file mode 100644 index a5300943..00000000 --- a/roles/test_ess.yml +++ /dev/null @@ -1,297 +0,0 @@ -# This Playbook contains test scenario for instance in classic network type -# Playbook created by : He Guimin - -- name: Testing Classic network type scenarions - hosts: localhost - connection: local - vars: - # general - alicloud_region: eu-central-1 - alicloud_zone: eu-central-1a - name: from-ansible-roles-test_ess - - # create vpc - cidr_block: 10.0.0.0/8 - - # create vswitch - vsw_cidr: 10.0.13.0/24 - - # create group - inboundRules: - - proto: tcp - port_range: 22/22 - cidr_ip: 0.0.0.0/0 - priority: 1 - - proto: tcp - port_range: 80/80 - cidr_ip: 0.0.0.0/0 - priority: 1 - outboundRules: - - proto: all - port_range: -1/-1 - cidr_ip: 0.0.0.0/0 - - # create instance - image: centos_6_09_64_20G_alibase_20170825.vhd - type: ecs.n4.small - host_name: myhost - password: pass@123 - count: 2 - allocate_public_ip: False - user_data: "#!/bin/sh\ncd /root\ntouch hahah\nwget http://wordpress.org/latest.tar.gz\n" - allocate_public_ip: True - internet_charge_type: PayByBandwidth - max_bandwidth_in: 200 - max_bandwidth_out: 10 - system_disk_category: cloud_efficiency - system_disk_size: 50 - - # create scaling group - max_size: 2 - min_size: 0 - cooldown: 400 - removal_policies: - - 'OldestScalingConfiguration' - - 'OldestInstance' - - # create scaling configuration - key_name: key-pair-for-ess - data_disks: - - size: 50 - category: cloud_efficiency - - tags: - CreatedBy: 'Ansible' - Version: '1' - - # create scaling rule - adjustment_type: QuantityChangeInCapacity - adjustment_value: 3 - - # create scheduled task - launch_time: 2018-01-10T08:00Z - launch_expiration: 300 - recurrence_type: 'Daily' - recurrence_value: 10 - recurrence_endtime: 2018-02-10T15:00Z - - tasks: - - name: Create VPC - ali_vpc: - alicloud_region: '{{ alicloud_region }}' - cidr_block: '{{ cidr_block }}' - vpc_name: '{{ name }}' - register: vpc - - debug: var=vpc - - # Create Vswitch - - name: Create VSwitch - ali_vswitch: - alicloud_region: '{{ alicloud_region }}' - alicloud_zone: '{{ alicloud_zone }}' - cidr_block: '{{ vsw_cidr }}' - vpc_id: '{{ vpc["vpc_id"] }}' - vswitch_name: '{{ name }}' - register: subnet - - debug: var=subnet - - - name: Creating security group - ali_security_group: - alicloud_region: '{{ alicloud_region }}' - name: '{{ name }}' - vpc_id: '{{ vpc.vpc_id }}' - rules: '{{ inboundRules }}' - rules_egress: '{{ outboundRules }}' - register: securitygroup - - debug: var=securitygroup - - - name: Create scaling group - ali_ess_group: - alicloud_region: '{{ alicloud_region }}' - max_size: '{{ max_size }}' - min_size: '{{ min_size }}' - name: '{{ name }}' - vswitch_ids: - - '{{ subnet.vswitch_id }}' - register: essgroup - - debug: var=essgroup - - - name: Create scaling configuration - ali_ess_configuration: - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ essgroup.id }}' - name: '{{ name }}' - image: '{{ image }}' - instance_type: '{{ type }}' - security_group_id: '{{ securitygroup.group_id }}' - internet_charge_type: '{{ internet_charge_type }}' - max_bandwidth_in: '{{ max_bandwidth_in }}' - max_bandwidth_out: '{{ max_bandwidth_out }}' - data_disks: '{{ data_disks }}' - tags: '{{ tags }}' - register: configuration - - debug: var=configuration - - - name: Create scaling configuration 2 - ali_ess_configuration: - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ essgroup.id }}' - name: '{{ name }}-2' - image: '{{ image }}' - instance_type: '{{ type }}' - security_group_id: '{{ securitygroup.group_id }}' - internet_charge_type: '{{ internet_charge_type }}' - max_bandwidth_in: '{{ max_bandwidth_in }}' - max_bandwidth_out: '{{ max_bandwidth_out }}' - data_disks: '{{ data_disks }}' - tags: '{{ tags }}' - register: configuration2 - - debug: var=configuration2 - - - name: Creating an ECS instance - ali_instance: - alicloud_region: '{{ alicloud_region }}' - image: '{{ image }}' - type: '{{ type }}' - instance_name: '{{ name }}' - host_name: '{{ host_name }}' - password: '{{ password }}' - group_id: '{{ securitygroup.group_id }}' - count: '{{ count }}' - allocate_public_ip: '{{ allocate_public_ip }}' - internet_charge_type: '{{ internet_charge_type }}' - max_bandwidth_in: '{{ max_bandwidth_in }}' - max_bandwidth_out: '{{ max_bandwidth_out }}' - instance_tags: '{{ tags }}' - vswitch_id: '{{ subnet.vswitch_id }}' - register: instance - - debug: var=instance - - - name: active scaling group - ali_ess_group: - alicloud_region: '{{ alicloud_region }}' - configuration_id: '{{ configuration.id }}' - id: '{{ essgroup.id }}' - state: active - - - name: remove auto-created instances - ali_ess_instance: - alicloud_region: '{{ alicloud_region }}' - creation_type: 'AutoCreated' - group_id: '{{ essgroup.id }}' - state: absent - - - name: add instances - ali_ess_instance: - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance.instance_ids }}' - group_id: '{{ essgroup.id }}' - - - name: remove instances - ali_ess_instance: - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance.instance_ids }}' - group_id: '{{ essgroup.id }}' - state: absent - - - name: create a scaling rule - ali_ess_rule: - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ essgroup.id }}' - adjustment_type: '{{adjustment_type}}' - adjustment_value: '{{adjustment_value}}' - cooldown: '{{cooldown}}' - name: '{{name}}' - register: rule - - debug: var=rule - - - name: modify a scaling rule - ali_ess_rule: - alicloud_region: '{{ alicloud_region }}' - cooldown: 800 - name: '{{name}}' - register: rule - - debug: var=rule - - - name: create a scheduled task - ali_ess_task: - alicloud_region: '{{ alicloud_region }}' - name: '{{ name }}' - rule_id: '{{ rule.id }}' - launch_time: '{{ launch_time }}' - launch_expiration: '{{ launch_expiration }}' - recurrence_type: '{{ recurrence_type }}' - recurrence_value: '{{ recurrence_value }}' - recurrence_endtime: '{{ recurrence_endtime }}' - register: task - - debug: var=task - - - name: modify a scheduled task - ali_ess_task: - alicloud_region: '{{ alicloud_region }}' - name: '{{ name }}' - description: "test modify task" - launch_expiration: 400 - register: modifytask - - debug: var=modifytask - - - name: delete a scheduled task - ali_ess_task: - alicloud_region: '{{ alicloud_region }}' - name: '{{ name }}' - state: absent - - - name: delete a scaling rule - ali_ess_rule: - alicloud_region: '{{ alicloud_region }}' - name: '{{ name }}' - state: absent - - - name: inactive scaling group - ali_ess_group: - alicloud_region: '{{ alicloud_region }}' - id: '{{ essgroup.id }}' - state: inactive - - - name: delete scaling configuration - ali_ess_configuration: - alicloud_region: '{{ alicloud_region }}' - id: '{{ configuration2.id }}' - state: absent - - - name: remove all of ECS instances - ali_ess_instance: - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ essgroup.id }}' - state: absent - - - name: delete scaling group - ali_ess_group: - alicloud_region: '{{ alicloud_region }}' - id: '{{ essgroup.id }}' - state: absent - - - name: Delete ECS instance - ali_instance: - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ instance.instance_ids }}' - force: True - state: 'absent' - - - name: Deleting security group - ali_security_group: - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ securitygroup.group_id }}' - state: absent - - - name: Deleting subnet - ali_vswitch: - alicloud_region: '{{ alicloud_region }}' - vswitch_id: '{{ subnet.vswitch_id }}' - state: absent - - - name: Deleting vpc - ali_vpc: - alicloud_region: '{{ alicloud_region }}' - vpc_id: '{{ vpc.vpc_id }}' - state: absent diff --git a/roles/test_oss.yml b/roles/test_oss.yml deleted file mode 100644 index a119957c..00000000 --- a/roles/test_oss.yml +++ /dev/null @@ -1,97 +0,0 @@ -- name: Test bucket Interfaces - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - bucket: bucketcomesfromansible - object: newobject-2 - folder_name: MeetingDocs - permission: public-read - content: "Hello word!" - file_name: 'test_oss.yml' - overwrite: true - headers: - Content-Encoding: md5 - - # download - byte_range: 0-200 - download_file: file_comes_from_oss.json - - tasks: - - name: create oss bucket - ali_oss_bucket: - alicloud_region: '{{ alicloud_region }}' - bucket: '{{ bucket }}' - permission: '{{ permission }}' - state: present - register: create_bucket_result - - debug: var=create_bucket_result - - - name: list oss buckets - ali_oss_bucket: - alicloud_region: '{{ alicloud_region }}' - bucket: '{{ bucket }}' - permission: '{{ permission }}' - state: list - register: list_buckets - - debug: var=list_buckets - - - name: upload content to bucket - ali_oss_object: - alicloud_region: '{{ alicloud_region }}' - bucket: '{{ bucket }}' - content: '{{ content }}' - headers: '{{ headers }}' - object: '{{ object }}' - mode: put - register: upload_result - - debug: var=upload_result - - - name: upload object via file - ali_oss_object: - alicloud_region: '{{ alicloud_region }}' - bucket: '{{ bucket }}' - file_name: '{{ file_name }}' - headers: '{{ headers }}' - object: '{{ object }}' -# overwrite: '{{ overwrite }}' - mode: put - register: file_upload_result - - debug: var=file_upload_result - - - name: download object - ali_oss_object: - alicloud_region: '{{ alicloud_region }}' - bucket: '{{ bucket }}' - file_name: '{{ download_file }}' - headers: '{{ headers }}' - range: '{{ byte_range }}' - object: '{{ object }}' - mode: get - register: download_result - - debug: var=download_result - - - name: list bucket objects - ali_oss_object: - alicloud_region: '{{ alicloud_region }}' - mode: list - bucket: '{{ bucket }}' - register: list_result - - debug: var=list_result - - - name: delete bucket object - ali_oss_object: - alicloud_region: '{{ alicloud_region }}' - mode: delete - bucket: '{{ bucket }}' - object: '{{ object }}' - register: delete_objects_result - - debug: var=delete_objects_result - - - name: delete oss bucket - ali_oss_bucket: - alicloud_region: '{{ alicloud_region }}' - bucket: '{{ bucket }}' - state: absent - register: delete_bucket_result - - debug: var=delete_bucket_result diff --git a/roles/test_rds_account.yml b/roles/test_rds_account.yml deleted file mode 100644 index 1d582736..00000000 --- a/roles/test_rds_account.yml +++ /dev/null @@ -1,81 +0,0 @@ -# This Playbook contains test scenario for Create, modify, restart, release RDS instance and change rds instance type, create and delete database , grant account permission and revoke acccount permission -# Playbook created by : - -- name: Testing - hosts: localhost - connection: local - vars: -#create rds instance - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-a -#create database - db_name: testtest -#create account - account_name: testdemoaccount - account_password: test@123 - description: - account_type: Normal - account_privilege: ReadOnly - - tasks: - - name: create account - alicloud_rds_account: - alicloud_region: '{{ alicloud_region }}' - state: present - db_instance_id: rm-2zey7ir50261bmg42 - account_name: '{{ account_name }}' - account_password: '{{ account_password }}' - description: '{{ description }}' - account_type: '{{ account_type }}' - register: result_create_account - - debug: var=result_create_account - - - name: grant account permission - alicloud_rds_account: - alicloud_region: '{{ alicloud_region }}' - state: present - db_instance_id: rm-2zey7ir50261bmg42 - db_name: '{{ db_name }}' - account_name: '{{ account_name }}' - account_privilege: '{{ account_privilege }}' - register: result_grant_permission - - debug: var=result_grant_permission - - - - name: revoke account permission - alicloud_rds_account: - alicloud_region: '{{ alicloud_region }}' - state: absent - db_instance_id: rm-2zey7ir50261bmg42 - db_name: '{{ db_name }}' - account_name: '{{ account_name }}' - register: result_revoke_permission - - debug: var=result_revoke_permission - - - name: Reset Instance Password - alicloud_rds_account: - alicloud_region: '{{ alicloud_region }}' - state: present - db_instance_id: rm-2zey7ir50261bmg42 - account_name: '{{ account_name }}' - account_password: "testasdasd" - register: resetting_instance_password - - debug: var=resetting_instance_password - - - name: Modify account description - alicloud_rds_account: - alicloud_region: '{{ alicloud_region }}' - state: present - db_instance_id: rm-2zey7ir50261bmg42 - account_name: '{{ account_name }}' - description: testmodify - register: resetting_instance_password - - - name: delete account - alicloud_rds_account: - alicloud_region: '{{ alicloud_region }}' - state: absent - db_instance_id: rm-2zey7ir50261bmg42 - account_name: '{{ account_name }}' - register: result_delete_account - - debug: var=result_delete_account diff --git a/roles/test_rds_instance.yml b/roles/test_rds_instance.yml deleted file mode 100644 index a41afd40..00000000 --- a/roles/test_rds_instance.yml +++ /dev/null @@ -1,98 +0,0 @@ -# This Playbook contains test scenario for Create, modify, restart, release RDS instance and change rds instance type, create and delete database , grant account permission and revoke acccount permission -# Playbook created by : - -- name: Testing - hosts: localhost - connection: local - vars: -#create rds instance - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-a - tasks: - - name: create rds instance - alicloud_rds_instance: - alicloud_region: '{{ alicloud_region }}' - state: present - engine: MySQL - engine_version: 5.6 - db_instance_class: rds.mysql.t1.small - db_instance_storage: 30 - db_instance_net_type: Internet - security_ip_list: 10.23.12.24/24 - pay_type: Postpaid - register: result_create_instance - - debug: var=result_create_instance - - - name: modify instance auto renewal attribute - alicloud_rds_instance: - alicloud_region: '{{ alicloud_region }}' - state: present -# db_instance_id: '{{ db_instance_id }}' - db_instance_id: '{{ result_create_instance["instance"]["db_instance_id"] }}' - auto_renew: False - register: result_grant_permission - - debug: var=result_grant_permission - - - - name: allocate instance private connection string - alicloud_rds_instance: - alicloud_region: '{{ alicloud_region }}' - state: present -# db_instance_id: '{{ db_instance_id }}' - db_instance_id: '{{ result_create_instance["instance"]["db_instance_id"] }}' - private_connection_string_prefix: pirave-89asd - register: result_grant_permission - - debug: var=result_grant_permission - -# - name: allocate instance public connection string -# alicloud_rds_instance: -# alicloud_region: '{{ alicloud_region }}' -# state: present -# db_instance_id: '{{ db_instance_id }}' -# db_instance_id: '{{ result_create_instance["instance"]["db_instance_id"] }}' -# public_connection_string_prefix: publicave-89asd -# public_port: 3165 -# register: result_grant_permission -# - debug: var=result_grant_permission - - - name: modify instance current connection string - alicloud_rds_instance: - alicloud_region: '{{ alicloud_region }}' - state: present -# db_instance_id: '{{ db_instance_id }}' - db_instance_id: '{{ result_create_instance["instance"]["db_instance_id"] }}' - current_connection_string: '{{ result_grant_permission["instance"]["connection_string"]}}' -# current_connection_string: daqwfadaw-3214das.mysql.rds.aliyuncs.com - dest_connection_string_prefix: new-3214dasdsa - dest_port: 3267 - register: result_grant_permission - - debug: var=result_grant_permission - - - name: delete instance public connection string - alicloud_rds_instance: - alicloud_region: '{{ alicloud_region }}' - state: absent -# db_instance_id: '{{ db_instance_id }}' - db_instance_id: '{{ result_create_instance["instance"]["db_instance_id"] }}' - current_connection_string: '{{ result_grant_permission["instance"]["connection_string"]}}' -# current_connection_string: aaaaaaaaaaa-3214das.mysql.rds.aliyuncs.com - register: result_grant_permission - - debug: var=result_grant_permission - - - name: restart rds instance - alicloud_rds_instance: - alicloud_region: '{{ alicloud_region }}' - state: restart - db_instance_id: '{{ result_create_instance["instance"]["db_instance_id"] }}' -# db_instance_id: '{{ db_instance_id }}' - register: result_grant_permission - - debug: var=result_grant_permission - - - name: delete rds instance - alicloud_rds_instance: - alicloud_region: '{{ alicloud_region }}' - state: absent - db_instance_id: '{{ result_create_instance["instance"]["db_instance_id"] }}' -# db_instance_id: '{{ db_instance_id }}' - register: result_grant_permission - - debug: var=result_grant_permission diff --git a/roles/test_slb.yml b/roles/test_slb.yml deleted file mode 100644 index 25dd1f62..00000000 --- a/roles/test_slb.yml +++ /dev/null @@ -1,72 +0,0 @@ -# This Playbook contains test scenario for Create SLB, Listener and add Backend Server -# Playbook created by : Guimin He - -- name: Testing Create SLB, Listener, Add Backend Server, Create, Set and Delete VServer Group - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - load_balancer_id: lb-2zeyfm5a14c9ffxvxmvco - - # create instance - alicloud_zone: cn-beijing-a - image: ubuntu_140405_64_40G_cloudinit_20161115.vhd - type: ecs.n4.small - instance_name: travis-ansible-instance - description: travis-ansible-instance - host_name: myhost - password: pass@123 - count: 2 - allocate_public_ip: yes - - tasks: - - name: Creating an ECS instance for Backend Server - ali_instance: - alicloud_region: '{{ alicloud_region }}' - alicloud_zone: '{{ alicloud_zone }}' - image: '{{ image }}' - type: '{{ type }}' - instance_name: '{{ instance_name }}' - description: '{{ description }}' - host_name: '{{ host_name }}' - password: '{{ password }}' - count: '{{ count }}' - allocate_public_ip: '{{ allocate_public_ip }}' - register: create_instance_result - - debug: var=create_instance_result - - - name: Set Backend Servers of SLB - ali_slb_server: - load_balancer_id: lb-2zeyfm5a14c9ffxvxmvco - state: present - backend_servers: - - server_id: '{{ create_instance_result.instance_ids[0] }}' - weight: 15 - - server_id: '{{ create_instance_result.instance_ids[1] }}' - weight: 20 - register: set_backend_server_result - - debug: var=set_backend_server_result - - - name: Describe Backend Servers of SLB - ali_slb_server: - load_balancer_id: lb-2zeyfm5a14c9ffxvxmvco - state: current - ports: 80 - register: describe_backend_server_result - - debug: var=describe_backend_server_result - - - name: Remove Backend Servers of SLB - ali_slb_server: - load_balancer_id: '{{ load_balancer_id }}' - state: absent - backend_servers: '{{ create_instance_result.instance_ids[0] }}' - register: remove_backend_server_result - - debug: var=remove_backend_server_result -# - - name: Deleting ECS instance - ali_instance: - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ create_instance_result.instance_ids }}' - state: 'absent' - register: delete_ecs_instance_result - - debug: var=delete_ecs_instance_result diff --git a/roles/test_slb_lb.yml b/roles/test_slb_lb.yml deleted file mode 100644 index 918372f2..00000000 --- a/roles/test_slb_lb.yml +++ /dev/null @@ -1,74 +0,0 @@ -# Basic provisioning example to set SLB Status -- name: set server load balancer status - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - load_balancer_name_for_change: test_change_name - address_type: internet - bandwidth: 4 - internet_charge_type: paybytraffic - tasks: - - name: create server load balancer - ali_slb_lb: - alicloud_region: '{{ alicloud_region }}' - state: present - register: create_result - - debug: var=create_result - - - name: list server load balancer - ali_slb_lb: - alicloud_region: '{{ alicloud_region }}' - state: list - register: result - - debug: var=result - - - name: set server load balancer status - ali_slb_lb: - alicloud_region: '{{ alicloud_region }}' - load_balancer_status: inactive - load_balancer_id: '{{ create_result["load_balancer"]["load_balancer_id" ] }}' -# load_balancer_id: '{{ load_balancer_id }}' - state: present - register: result - - debug: var=result - - - name: set server load balancer status - ali_slb_lb: - alicloud_region: '{{ alicloud_region }}' - load_balancer_status: active -# load_balancer_id: '{{ load_balancer_id }}' - load_balancer_id: '{{ create_result["load_balancer"]["load_balancer_id" ] }}' - state: present - register: result - - debug: var=result - - - name: modify server load balancer internet specification - ali_slb_lb: - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ create_result["load_balancer"]["load_balancer_id" ] }}' -# load_balancer_id: '{{ load_balancer_id }}' - internet_charge_type: '{{ internet_charge_type }}' - bandwidth: '{{ bandwidth }}' - state: present - register: result - - debug: var=result - - - name: set server load balancer name - ali_slb_lb: - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ create_result["load_balancer"]["load_balancer_id" ] }}' -# load_balancer_id: '{{ load_balancer_id }}' - load_balancer_name: '{{ load_balancer_name_for_change }}' - state: present - register: result - - debug: var=result - - - name: delete server load balancer - ali_slb_lb: - alicloud_region: '{{ alicloud_region }}' -# load_balancer_id: '{{ load_balancer_id }}' - load_balancer_id: '{{ create_result["load_balancer"]["load_balancer_id" ] }}' - state: absent - register: result - - debug: var=result diff --git a/roles/test_slb_listerner.yml b/roles/test_slb_listerner.yml deleted file mode 100644 index a5600f99..00000000 --- a/roles/test_slb_listerner.yml +++ /dev/null @@ -1,75 +0,0 @@ -# This Playbook contains test scenario for Create SLB, Listener and add Backend Server -# Playbook created by : Guimin He - -- name: Create listener - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-a - - tasks: - - name: create server load balancer - ali_slb_lb: - alicloud_region: '{{ alicloud_region }}' - name: "test-alb-ansible" - state: present - register: slb - - - name: Creating tcp listener - ali_slb_listener: - alicloud_region: '{{ alicloud_region }}' - protocol: tcp - load_balancer_id: '{{ slb.load_balancer.id }}' - listener_port: 443 - backend_server_port: 443 - bandwidth: 4 - sticky_session: off - state: present - register: tcp - - - name: stop listener - ali_slb_listener: - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ slb.load_balancer.id }}' - listener_port: 443 - state: stopped - - - name: delete listener - ali_slb_listener: - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ slb.load_balancer.id }}' - listener_port: 443 - state: absent - - - name: Creating http listener - ali_slb_listener: - alicloud_region: '{{ alicloud_region }}' - protocol: http - load_balancer_id: '{{ slb.load_balancer.id }}' - listener_port: 80 - backend_server_port: 80 - bandwidth: 4 - sticky_session: off - state: present - register: tcp - - - name: stop listener - ali_slb_listener: - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ slb.load_balancer.id }}' - listener_port: 80 - state: stopped - - - name: delete listener - ali_slb_listener: - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ slb.load_balancer.id }}' - listener_port: 80 - state: absent - - - name: delete load balancer - ali_slb_lb: - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ slb.load_balancer.id }}' - state: absent \ No newline at end of file diff --git a/roles/test_slb_test.yml b/roles/test_slb_test.yml deleted file mode 100644 index 1e98b5c5..00000000 --- a/roles/test_slb_test.yml +++ /dev/null @@ -1,74 +0,0 @@ -# Basic provisioning example to set SLB Status -- name: set server load balancer status - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - load_balancer_name_for_change: test_change_name - address_type: internet - bandwidth: 4 - internet_charge_type: paybytraffic - tasks: - - name: create server load balancer - alicloud_slb_lb: - alicloud_region: '{{ alicloud_region }}' - state: present - register: create_result - - debug: var=create_result - - - name: list server load balancer - alicloud_slb_lb: - alicloud_region: '{{ alicloud_region }}' - state: list - register: result - - debug: var=result - - - name: set server load balancer status - alicloud_slb_lb: - alicloud_region: '{{ alicloud_region }}' - load_balancer_status: inactive - load_balancer_id: '{{ create_result["load_balancer"]["load_balancer_id" ] }}' -# load_balancer_id: '{{ load_balancer_id }}' - state: present - register: result - - debug: var=result - - - name: set server load balancer status - alicloud_slb_lb: - alicloud_region: '{{ alicloud_region }}' - load_balancer_status: active -# load_balancer_id: '{{ load_balancer_id }}' - load_balancer_id: '{{ create_result["load_balancer"]["load_balancer_id" ] }}' - state: present - register: result - - debug: var=result - - - name: modify server load balancer internet specification - alicloud_slb_lb: - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ create_result["load_balancer"]["load_balancer_id" ] }}' -# load_balancer_id: '{{ load_balancer_id }}' - internet_charge_type: '{{ internet_charge_type }}' - bandwidth: '{{ bandwidth }}' - state: present - register: result - - debug: var=result - - - name: set server load balancer name - alicloud_slb_lb: - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: '{{ create_result["load_balancer"]["load_balancer_id" ] }}' -# load_balancer_id: '{{ load_balancer_id }}' - load_balancer_name: '{{ load_balancer_name_for_change }}' - state: present - register: result - - debug: var=result - - - name: delete server load balancer - alicloud_slb_lb: - alicloud_region: '{{ alicloud_region }}' -# load_balancer_id: '{{ load_balancer_id }}' - load_balancer_id: '{{ create_result["load_balancer"]["load_balancer_id" ] }}' - state: absent - register: result - - debug: var=result diff --git a/roles/test_slb_vsg.yml b/roles/test_slb_vsg.yml deleted file mode 100644 index a948f2e3..00000000 --- a/roles/test_slb_vsg.yml +++ /dev/null @@ -1,71 +0,0 @@ -# This Playbook contains test scenario for Create SLB, Listener and add Backend Server -# Playbook created by : Guimin He - -- name: Create listener - hosts: localhost - connection: local - vars: - alicloud_region: cn-beijing - alicloud_zone: cn-beijing-a - - tasks: - - name: Creating an vsg - ali_slb_vsg: - alicloud_region: '{{ alicloud_region }}' - load_balancer_id: lb-2zehfr9wsqo2lfkhzue66 - vserver_group_name: Group123 - backend_servers: - - instance_id: i-2ze3ajpeq3y80w4lt4jr - port: 80 - weight: 100 - state: present - register: create_vsg_result - - debug: var=create_vsg_result - - - name: set vsg attribute - ali_slb_vsg: - alicloud_region: '{{ alicloud_region }}' - vserver_group_id: '{{ create_vsg_result["vserver_group"]["vserver_group_id"] }}' - vserver_group_name: test_set - state: present - register: del_vsg_result - - debug: var=del_vsg_result - - - name: add backend server - ali_slb_vsg: - alicloud_region: '{{ alicloud_region }}' - vserver_group_id: '{{ create_vsg_result["vserver_group"]["vserver_group_id"] }}' - backend_servers: - - instance_id: i-2ze3ajpeq3y80w4lt4jr - port: 90 - weight: 100 - state: present - register: del_vsg_result - - debug: var=del_vsg_result - - - name: remove backend server - ali_slb_vsg: - alicloud_region: '{{ alicloud_region }}' - vserver_group_id: '{{ create_vsg_result["vserver_group"]["vserver_group_id"] }}' - backend_servers: - - instance_id: i-2ze3ajpeq3y80w4lt4jr - port: 90 - state: absent - register: del_vsg_result - - debug: var=del_vsg_result - - - name: list vsg - ali_slb_vsg: - alicloud_region: '{{ alicloud_region }}' - vserver_group_id: '{{ create_vsg_result["vserver_group"]["vserver_group_id"] }}' - state: list - register: del_vsg_result - - debug: var=del_vsg_result - - - name: delete vsg - ali_slb_vsg: - alicloud_region: '{{ alicloud_region }}' - vserver_group_id: '{{ create_vsg_result["vserver_group"]["vserver_group_id"] }}' - state: absent - register: del_vsg_result - - debug: var=del_vsg_result diff --git a/roles/test_vpc.yml b/roles/test_vpc.yml deleted file mode 100644 index 6298176c..00000000 --- a/roles/test_vpc.yml +++ /dev/null @@ -1,201 +0,0 @@ -# This Playbook contains test scenario for vpc -# Playbook created by : Guimin He - -- name: Create VPC - hosts: localhost - connection: local - vars: - # create vpc - alicloud_region: cn-beijing - state: present - stateDel: absent - cidr_block: 10.0.0.0/8 - vpc_name: travis-ansible-vpc - description: travis-ansible-vpc - # create vswitch - vsw_cidr: 10.0.13.0/24 - vsw_name: Test_Vswitch - alicloud_zone: cn-beijing-a - vsw_description: Test vswitch created - - # create group - sg_name: travis-ansible-instance - inboundRules: - - proto: tcp - port_range: 22/22 - cidr_ip: 0.0.0.0/0 - priority: 1 - - - proto: tcp - port_range: 80/80 - cidr_ip: 0.0.0.0/0 - priority: 1 - - - proto: udp - port_range: 10988/10989 - cidr_ip: 47.89.23.33/32 - priority: 2 - - outboundRules: - - proto: tcp - port_range: 80/80 - cidr_ip: 192.168.0.54/32 - priority: 1 - - - proto: tcp - port_range: 8080/8085 - cidr_ip: 47.89.23.33/32 - priority: 1 - - - proto: udp - port_range: 10989/10997 - cidr_ip: 47.89.23.33/32 - priority: 2 - - # Eip Realted interface - internetChargeType: PayByTraffic - bandwidth: 7 - - # create ecs instance connected to the switch - image: ubuntu_14_0405_64_40G_base_20170222.vhd - type: ecs.n4.small - instance_name: travis-ansible-vpc-instance - host_name: myhost - password: pass@123 - count: 1 - allocate_public_ip: False - user_data: "#!/bin/sh\ncd /root\ntouch hahah\nwget http://wordpress.org/latest.tar.gz\n" - - # create route entry - destination_cidrblock: 10.0.14.0/24 - - tasks: - - name: Create VPC - ali_vpc: - alicloud_region: '{{ alicloud_region }}' - state: '{{ state }}' - cidr_block: '{{ cidr_block }}' - vpc_name: '{{ vpc_name }}' - description: '{{ description }}' - register: create_vpc - - debug: var=create_vpc - - # Create Vswitch - - name: Create VSwitch - ali_vswitch: - alicloud_region: '{{ alicloud_region }}' - alicloud_zone: '{{ alicloud_zone }}' - state: '{{ state }}' - cidr_block: '{{ vsw_cidr }}' - vswitch_name: '{{ vsw_name }}' - description: '{{ description }}' - vpc_id: '{{ create_vpc["vpc_id"] }}' - register: create_vsw - - debug: var=create_vsw - - - name: Creating security group - ali_security_group: - alicloud_region: '{{ alicloud_region }}' - name: '{{ sg_name }}' - description: '{{description}}' - vpc_id: '{{ create_vpc.vpc_id }}' - rules: '{{ inboundRules }}' - rules_egress: '{{ outboundRules }}' - register: createsgeresult - - debug: var=createsgeresult - - - name: Creating an ECS instance - ali_instance: - alicloud_region: '{{ alicloud_region }}' - image: '{{ image }}' - type: '{{ type }}' - instance_name: '{{ instance_name }}' - description: '{{ description }}' - host_name: '{{ host_name }}' - password: '{{ password }}' - count: '{{ count }}' - group_id: '{{ createsgeresult.group_id }}' - allocate_public_ip: '{{ allocate_public_ip }}' - vswitch_id: '{{ create_vsw.vswitch_id }}' - user_data: '{{ user_data }}' - register: create_instance_result - - debug: var=create_instance_result - - # create route entry - - name: Create route entry - ali_route_entry: - alicloud_region: '{{ alicloud_region }}' - state: '{{ state }}' - nexthop_id: '{{ create_instance_result["instance_ids"][0] }}' - router_id: '{{ create_vpc["vpc"]["router_id"] }}' - destination_cidrblock: '{{ destination_cidrblock }}' - register: create_route_entry - - debug: var=create_route_entry - - - name: allocating an eip - ali_eip: - alicloud_region: '{{ alicloud_region }}' - internet_charge_type: '{{ internetChargeType }}' - bandwidth: '{{ bandwidth }}' - ip_address: '47.93.2.116' - state: present - register: new_eip - - - name: associate the created EIP with an ECS instance - ali_eip: - alicloud_region: '{{ alicloud_region }}' - bandwidth: '{{bandwidth}}' - ip_address: '{{ new_eip.ip_address }}' - instance_id: '{{ create_instance_result["instance_ids"][0] }}' - state: present - - - name: disassociate the created EIP with an ECS instance - ali_eip: - alicloud_region: '{{ alicloud_region }}' - bandwidth: '{{bandwidth}}' - ip_address: '{{ new_eip.ip_address }}' - instance_id: '{{ create_instance_result["instance_ids"][0] }}' - state: absent - - - name: release the created EIP - ali_eip: - alicloud_region: '{{ alicloud_region }}' - ip_address: '{{ new_eip.ip_address }}' - state: absent - - - name: Delete route entry - ali_route_entry: - alicloud_region: '{{ alicloud_region }}' - state: absent - destination_cidrblock: '{{ create_route_entry["destination_cidrblock"] }}' - nexthop_id: '{{ create_instance_result["instance_ids"][0]}}' - router_id: '{{ create_vpc["vpc"]["router_id"] }}' - register: delete_route_entry - - debug: var=delete_route_entry -# - - name: Delete ECS Instance - ali_instance: - alicloud_region: '{{ alicloud_region }}' - instance_ids: '{{ create_instance_result["instance_ids"][0] }}' - force: true - state: absent - - # Delete Vsitches with vpc_id and vswitch_ids - - name: Delete Vswitch - ali_vswitch: - state: absent - alicloud_region: '{{ alicloud_region }}' - vpc_id: '{{ create_vpc["vpc_id"] }}' - vswitch_id: '{{ create_vsw["vswitch_id"] }}' - - - name: Delete Security Group - ali_security_group: - state: absent - alicloud_region: '{{ alicloud_region }}' - group_id: '{{ createsgeresult.group_id }}' - - - name: Delete VPC - ali_vpc: - alicloud_region: '{{ alicloud_region }}' - vpc_id: '{{ create_vpc["vpc_id"] }}' - state: '{{ stateDel }}' \ No newline at end of file diff --git a/setup.py b/setup.py index f994fc5c..e69de29b 100644 --- a/setup.py +++ b/setup.py @@ -1,63 +0,0 @@ -#!/usr/bin/env python -# Always prefer setuptools over distutils -from codecs import open -from os import path - -try: - from setuptools import setup, find_packages - - extra = dict(test_suite="tests.test.suite", include_package_data=True) -except ImportError: - from distutils.core import setup - - extra = {} - -NAME = "ansible_alicloud" -DESCRIPTION = "Ansible provider for Alicloud." -AUTHOR = "xiaozhu" -AUTHOR_EMAIL = "heguimin36@163.com" -URL = "https://github.com/alibaba/ansible-provider/tree/master/lib/ansible" - -VERSION = "1.19.0" - -setup( - name=NAME, - - # Versions should comply with PEP440. For a discussion on single-sourcing - # the version across setup.py and the project code, see - # https://packaging.python.org/en/latest/single_source_version.html - # version=PROVIDER_VERSION, - version=VERSION, - description=DESCRIPTION, - - url=URL, - - # Author details - author=AUTHOR, - author_email=AUTHOR_EMAIL, - - # Choose your license - license='MIT', - - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - 'Development Status :: 3 - Alpha', - - # Indicate who your project is intended for - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Build Tools', - - # Pick your license as you wish (should match "license" above) - 'License :: OSI Approved :: MIT License', - - # Specify the Python versions you support here. In particular, ensure - # that you indicate whether you support Python 3. - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - ], - - package_dir={'': 'lib'}, - packages=find_packages('lib'), - include_package_data=True, - install_requires=['ansible', 'footmark>=1.20.0', 'ansible_alicloud_module_utils>=1.5.0', 'ruamel.yaml==0.10.2'] -)