| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
from __future__ import absolute_import, division, print_function |
| 8 |
__metaclass__ = type |
| 9 |
|
| 10 |
|
| 11 |
DOCUMENTATION = ''' |
| 12 |
--- |
| 13 |
module: azure_rm_aksagentpool |
| 14 |
version_added: '1.14.0' |
| 15 |
short_description: Manage node pools in Kubernetes kubernetes cluster |
| 16 |
description: |
| 17 |
- Create, update or delete node pools in kubernetes cluster. |
| 18 |
|
| 19 |
options: |
| 20 |
resource_group: |
| 21 |
description: |
| 22 |
- The name of the resource group. |
| 23 |
type: str |
| 24 |
required: True |
| 25 |
cluster_name: |
| 26 |
description: |
| 27 |
- The name of the kubernetes cluster. |
| 28 |
type: str |
| 29 |
required: True |
| 30 |
name: |
| 31 |
description: |
| 32 |
- The name of the node agent pool. |
| 33 |
type: str |
| 34 |
required: True |
| 35 |
count: |
| 36 |
description: |
| 37 |
- Number of agents (VMs) to host docker containers. |
| 38 |
type: int |
| 39 |
vm_size: |
| 40 |
description: |
| 41 |
- Size of agent VMs |
| 42 |
type: str |
| 43 |
os_disk_size_gb: |
| 44 |
description: |
| 45 |
- OS Disk Size in GB to be used to specify the disk size for every machine in this master/agent pool. |
| 46 |
type: int |
| 47 |
vnet_subnet_id: |
| 48 |
description: |
| 49 |
- VNet SubnetID specifies the VNet's subnet identifier. |
| 50 |
type: str |
| 51 |
availability_zones: |
| 52 |
description: |
| 53 |
- Availability zones for nodes. Must use VirtualMachineScaleSets AgentPoolType. |
| 54 |
type: list |
| 55 |
elements: int |
| 56 |
choices: |
| 57 |
- 1 |
| 58 |
- 2 |
| 59 |
- 3 |
| 60 |
os_type: |
| 61 |
description: |
| 62 |
- OsType to be used to specify os type. |
| 63 |
type: str |
| 64 |
choices: |
| 65 |
- Linux |
| 66 |
- Windows |
| 67 |
- linux |
| 68 |
- windows |
| 69 |
orchestrator_version: |
| 70 |
description: |
| 71 |
- Version of orchestrator specified when creating the managed cluster. |
| 72 |
type: str |
| 73 |
type_properties_type: |
| 74 |
description: |
| 75 |
- AgentPoolType represents types of an agent pool. |
| 76 |
type: str |
| 77 |
choices: |
| 78 |
- VirtualMachineScaleSets |
| 79 |
- AvailabilitySet |
| 80 |
mode: |
| 81 |
description: |
| 82 |
- AgentPoolMode represents mode of an agent pool. |
| 83 |
type: str |
| 84 |
choices: |
| 85 |
- System |
| 86 |
- User |
| 87 |
enable_auto_scaling: |
| 88 |
description: |
| 89 |
- Whether to enable auto-scaler. |
| 90 |
type: bool |
| 91 |
max_count: |
| 92 |
description: |
| 93 |
- Maximum number of nodes for auto-scaling. |
| 94 |
type: int |
| 95 |
node_labels: |
| 96 |
description: |
| 97 |
- Agent pool node labels to be persisted across all nodes in agent pool. |
| 98 |
type: dict |
| 99 |
node_taints: |
| 100 |
description: |
| 101 |
- The taints added to new nodes during node pool create and scale. |
| 102 |
- For example as example, value:NoSchedule'. |
| 103 |
type: list |
| 104 |
elements: str |
| 105 |
min_count: |
| 106 |
description: |
| 107 |
- Minimum number of nodes for auto-scaling. |
| 108 |
type: int |
| 109 |
max_pods: |
| 110 |
description: |
| 111 |
- Maximum number of pods that can run on a node. |
| 112 |
type: int |
| 113 |
kubelet_disk_type: |
| 114 |
description: |
| 115 |
- Determines the placement of emptyDir volumes, container runtime data root, and Kubelet ephemeral storage. |
| 116 |
type: str |
| 117 |
choices: |
| 118 |
- OS |
| 119 |
- Temporary |
| 120 |
workload_runtime: |
| 121 |
description: |
| 122 |
- Determines the type of workload a node can run. |
| 123 |
type: str |
| 124 |
choices: |
| 125 |
- OCIContainer |
| 126 |
- WasmWasi |
| 127 |
os_sku: |
| 128 |
description: |
| 129 |
- Specifies an OS SKU. |
| 130 |
- This value must not be specified if OSType is Windows. |
| 131 |
- The I(os_sku=CBLMariner) deprecated. Microsoft recommends that new deployments choose 'AzureLinux' instead. |
| 132 |
type: str |
| 133 |
choices: |
| 134 |
- Ubuntu |
| 135 |
- AzureLinux |
| 136 |
- Windows2019 |
| 137 |
- Windows2022 |
| 138 |
scale_down_mode: |
| 139 |
description: |
| 140 |
- This also effects the cluster autoscaler behavior. |
| 141 |
- If not specified, it defaults to C(Delete). |
| 142 |
type: str |
| 143 |
default: Delete |
| 144 |
choices: |
| 145 |
- Delete |
| 146 |
- Deallocate |
| 147 |
upgrade_settings: |
| 148 |
description: |
| 149 |
- Settings for upgrading the agentpool. |
| 150 |
type: dict |
| 151 |
suboptions: |
| 152 |
max_surge: |
| 153 |
description: |
| 154 |
- This can either be set to an integer, sucha as C(5) or percentage C(50%). |
| 155 |
- If a percentage is specified, it is the percentage of the total agent pool size at the time of the upgrade. |
| 156 |
- For percentages, fractional nodes are rounded up. |
| 157 |
- If not specified, the default is C(1). |
| 158 |
type: str |
| 159 |
power_state: |
| 160 |
description: |
| 161 |
- When an Agent Pool is first created it is initially C(Running). |
| 162 |
- The Agent Pool can be stopped by setting this field to C(Stopped). |
| 163 |
- A stopped Agent Pool stops all of its VMs and does not accrue billing charges. |
| 164 |
- An Agent Pool can only be stopped if it is Running and provisioning state is Succeeded. |
| 165 |
type: dict |
| 166 |
suboptions: |
| 167 |
code: |
| 168 |
description: |
| 169 |
- Tells whether the cluster is C(Running) or C(Stopped). |
| 170 |
type: str |
| 171 |
choices: |
| 172 |
- Running |
| 173 |
- Stopped |
| 174 |
enable_node_public_ip: |
| 175 |
description: |
| 176 |
- Some scenarios may require nodes in a node pool to receive theirown dedicated public IP addresses. |
| 177 |
- A common scenario is for gaming workloads, where a console needs to make a direct connection to a cloud virtual machine to minimize hops. |
| 178 |
type: bool |
| 179 |
scale_set_priority: |
| 180 |
description: |
| 181 |
- The Virtual Machine Scale Set priority. |
| 182 |
- If not specified, the default is C(Regular). |
| 183 |
type: str |
| 184 |
choices: |
| 185 |
- Spot |
| 186 |
- Regular |
| 187 |
node_public_ip_prefix_id: |
| 188 |
description: |
| 189 |
- The Azure Public IP prefix's ID. |
| 190 |
type: str |
| 191 |
scale_set_eviction_policy: |
| 192 |
description: |
| 193 |
- This cannot be specified unless the I(scale_set_priority=Spot). |
| 194 |
- If not specified, the default is C(Delete). |
| 195 |
type: str |
| 196 |
choices: |
| 197 |
- Delete |
| 198 |
- Deallocate |
| 199 |
spot_max_price: |
| 200 |
description: |
| 201 |
- Possible values are any decimal value greater than zero or -1. |
| 202 |
- Indicates the willingness to pay any on-demand price. |
| 203 |
type: float |
| 204 |
proximity_placement_group_id: |
| 205 |
description: |
| 206 |
- The ID for Proximity Placement Group. |
| 207 |
type: str |
| 208 |
kubelet_config: |
| 209 |
description: |
| 210 |
- The Kubelet configuration on the agent pool nodes. |
| 211 |
type: dict |
| 212 |
suboptions: |
| 213 |
cpu_manager_policy: |
| 214 |
description: |
| 215 |
- Kubernetes CPU management policies. |
| 216 |
- The default is C(none). |
| 217 |
type: str |
| 218 |
default: none |
| 219 |
choices: |
| 220 |
- none |
| 221 |
- static |
| 222 |
cpu_cfs_quota: |
| 223 |
description: |
| 224 |
- The default is C(true). |
| 225 |
type: bool |
| 226 |
default: true |
| 227 |
cpu_cfs_quota_period: |
| 228 |
description: |
| 229 |
- The default is C(100ms). |
| 230 |
- Valid values are a sequence of decimal numbers with an optional fraction and a unit suffix. |
| 231 |
type: str |
| 232 |
default: 100ms |
| 233 |
image_gc_high_threshold: |
| 234 |
description: |
| 235 |
- To disable image garbage collection, set to C(100). |
| 236 |
- The default is C(85) |
| 237 |
type: int |
| 238 |
default: 85 |
| 239 |
image_gc_low_threshold: |
| 240 |
description: |
| 241 |
- This cannot be set higher than imageGcHighThreshold. |
| 242 |
- The default is C(80). |
| 243 |
type: int |
| 244 |
default: 80 |
| 245 |
topology_manager_policy: |
| 246 |
description: |
| 247 |
- Kubernetes Topology Manager policies. |
| 248 |
- The default is C(none). |
| 249 |
type: str |
| 250 |
default: none |
| 251 |
choices: |
| 252 |
- none |
| 253 |
- best-effort |
| 254 |
- restricted |
| 255 |
- single-numa-node |
| 256 |
allowed_unsafe_sysctls: |
| 257 |
description: |
| 258 |
- Allowed list of unsafe sysctls or unsafe sysctl patterns. |
| 259 |
type: list |
| 260 |
elements: str |
| 261 |
fail_swap_on: |
| 262 |
description: |
| 263 |
- If set to true it will make the Kubelet fail to start if swap is enabled on the node. |
| 264 |
type: bool |
| 265 |
container_log_max_size_mb: |
| 266 |
description: |
| 267 |
- The maximum size of container log file before it is rotated. |
| 268 |
type: int |
| 269 |
container_log_max_files: |
| 270 |
description: |
| 271 |
- The maximum number of container log files that can be present for a container. The number must be ≥ 2. |
| 272 |
type: int |
| 273 |
pod_max_pids: |
| 274 |
description: |
| 275 |
- The maximum number of processes per pod. |
| 276 |
type: int |
| 277 |
linux_os_config: |
| 278 |
description: |
| 279 |
- The OS configuration of Linux agent nodes. |
| 280 |
type: dict |
| 281 |
suboptions: |
| 282 |
sysctls: |
| 283 |
description: |
| 284 |
- Sysctl settings for Linux agent nodes. |
| 285 |
type: dict |
| 286 |
suboptions: |
| 287 |
net_core_somaxconn: |
| 288 |
description: |
| 289 |
- Sysctl setting net.core.somaxconn. |
| 290 |
type: int |
| 291 |
net_core_netdev_max_backlog: |
| 292 |
description: |
| 293 |
- Sysctl setting net.core.netdev_max_backlog. |
| 294 |
type: int |
| 295 |
net_core_rmem_default: |
| 296 |
description: |
| 297 |
- Sysctl setting net.core.rmem_default. |
| 298 |
type: int |
| 299 |
net_core_rmem_max: |
| 300 |
description: |
| 301 |
- Sysctl setting net.core.rmem_max. |
| 302 |
type: int |
| 303 |
net_core_wmem_default: |
| 304 |
description: |
| 305 |
- Sysctl setting net.core.wmem_default. |
| 306 |
type: int |
| 307 |
net_core_wmem_max: |
| 308 |
description: |
| 309 |
- Sysctl setting net.core.wmem_max. |
| 310 |
type: int |
| 311 |
net_core_optmem_max: |
| 312 |
description: |
| 313 |
- Sysctl setting net.core.optmem_max. |
| 314 |
type: int |
| 315 |
net_ipv4_tcp_max_syn_backlog: |
| 316 |
description: |
| 317 |
- Sysctl setting net.ipv4.tcp_max_syn_backlog. |
| 318 |
type: int |
| 319 |
net_ipv4_tcp_max_tw_buckets: |
| 320 |
description: |
| 321 |
- Sysctl setting net.ipv4.tcp_max_tw_buckets. |
| 322 |
type: int |
| 323 |
net_ipv4_tcp_fin_timeout: |
| 324 |
description: |
| 325 |
- Sysctl setting net.ipv4.tcp_fin_timeout. |
| 326 |
type: int |
| 327 |
net_ipv4_tcp_keepalive_time: |
| 328 |
description: |
| 329 |
- Sysctl setting net.ipv4.tcp_keepalive_time. |
| 330 |
type: int |
| 331 |
net_ipv4_tcp_keepalive_probes: |
| 332 |
description: |
| 333 |
- Sysctl setting net.ipv4.tcp_keepalive_probes. |
| 334 |
type: int |
| 335 |
net_ipv4_tcpkeepalive_intvl: |
| 336 |
description: |
| 337 |
- Sysctl setting net.ipv4.tcp_keepalive_intvl. |
| 338 |
type: int |
| 339 |
net_ipv4_tcp_tw_reuse: |
| 340 |
description: |
| 341 |
- Sysctl setting net.ipv4.tcp_tw_reuse. |
| 342 |
type: bool |
| 343 |
net_ipv4_ip_local_port_range: |
| 344 |
description: |
| 345 |
- Sysctl setting net.ipv4.ip_local_port_range. |
| 346 |
type: str |
| 347 |
net_ipv4_neigh_default_gc_thresh1: |
| 348 |
description: |
| 349 |
- Sysctl setting net.ipv4.neigh.default.gc_thresh1. |
| 350 |
type: int |
| 351 |
net_ipv4_neigh_default_gc_thresh2: |
| 352 |
description: |
| 353 |
- Sysctl setting net.ipv4.neigh.default.gc_thresh2. |
| 354 |
type: int |
| 355 |
net_ipv4_neigh_default_gc_thresh3: |
| 356 |
description: |
| 357 |
- Sysctl setting net.ipv4.neigh.default.gc_thresh3. |
| 358 |
type: int |
| 359 |
fs_inotify_max_user_watches: |
| 360 |
description: |
| 361 |
- Sysctl setting fs.inotify.max_user_watches. |
| 362 |
type: int |
| 363 |
fs_file_max: |
| 364 |
description: |
| 365 |
- Sysctl setting fs.file-max. |
| 366 |
type: int |
| 367 |
fs_aio_max_nr: |
| 368 |
description: |
| 369 |
- Sysctl setting fs.aio-max-nr. |
| 370 |
type: int |
| 371 |
fs_nr_open: |
| 372 |
description: |
| 373 |
- Sysctl setting fs.nr_open. |
| 374 |
type: int |
| 375 |
kernel_threads_max: |
| 376 |
description: |
| 377 |
- Sysctl setting kernel.threads-max. |
| 378 |
type: int |
| 379 |
vm_max_map_count: |
| 380 |
description: |
| 381 |
- Sysctl setting vm.max_map_count. |
| 382 |
type: int |
| 383 |
vm_swappiness: |
| 384 |
description: |
| 385 |
- Sysctl setting vm.swappiness. |
| 386 |
type: int |
| 387 |
vm_vfs_cache_pressure: |
| 388 |
description: |
| 389 |
- Sysctl setting vm.vfs_cache_pressure. |
| 390 |
type: int |
| 391 |
net_netfilter_nf_conntrack_max: |
| 392 |
description: |
| 393 |
- sysctl setting net.netfilter.nf_conntrack_max. |
| 394 |
type: int |
| 395 |
net_netfilter_nf_conntrack_buckets: |
| 396 |
description: |
| 397 |
- Sysctl setting net.netfilter.nf_conntrack_buckets. |
| 398 |
type: int |
| 399 |
transparent_huge_page_enabled: |
| 400 |
description: |
| 401 |
- The node agent pool transparent hugepage. |
| 402 |
- The default is C(always). |
| 403 |
type: str |
| 404 |
default: always |
| 405 |
choices: |
| 406 |
- always |
| 407 |
- madvise |
| 408 |
- never |
| 409 |
transparent_huge_page_defrag: |
| 410 |
description: |
| 411 |
- The node agent pool transparent huge page deferag. |
| 412 |
- The default is C(madvise). |
| 413 |
type: str |
| 414 |
default: madvise |
| 415 |
choices: |
| 416 |
- always |
| 417 |
- defer |
| 418 |
- defer+madvise |
| 419 |
- madvise |
| 420 |
- never |
| 421 |
swap_file_size_mb: |
| 422 |
description: |
| 423 |
- The size in MB of a swap file that will be created on each node. |
| 424 |
type: int |
| 425 |
enable_encryption_at_host: |
| 426 |
description: |
| 427 |
- This is only supported on certain VM sizes and in certain Azure regions. |
| 428 |
type: bool |
| 429 |
enable_ultra_ssd: |
| 430 |
description: |
| 431 |
- Whether to enable UltraSSD. |
| 432 |
type: bool |
| 433 |
enable_fips: |
| 434 |
description: |
| 435 |
- Whether enable FIPS node pool. |
| 436 |
type: bool |
| 437 |
gpu_instance_profile: |
| 438 |
description: |
| 439 |
- GPUInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU. |
| 440 |
type: str |
| 441 |
choices: |
| 442 |
- MIG1g |
| 443 |
- MIG2g |
| 444 |
- MIG3g |
| 445 |
- MIG4g |
| 446 |
- MIG7g |
| 447 |
security_profile: |
| 448 |
description: |
| 449 |
- The security settings of an agent pool. |
| 450 |
type: dict |
| 451 |
suboptions: |
| 452 |
enable_vtpm: |
| 453 |
description: |
| 454 |
- Whether to disable or enabled the vTPM. |
| 455 |
type: bool |
| 456 |
default: false |
| 457 |
enable_secure_boot: |
| 458 |
description: |
| 459 |
- Whether to disable or enabled the secure boot. |
| 460 |
default: false |
| 461 |
type: bool |
| 462 |
os_disk_type: |
| 463 |
description: |
| 464 |
- The default is C(Ephemeral) if the VM supports it and has a cache disk larger than the requested OSDiskSizeGB. |
| 465 |
- Otherwise, defaults to C(Managed). |
| 466 |
- May not be changed after creation. |
| 467 |
type: str |
| 468 |
choices: |
| 469 |
- Ephemeral |
| 470 |
- Managed |
| 471 |
capacity_reservation_group_id: |
| 472 |
description: |
| 473 |
- The Capacity Reservation Group ID. |
| 474 |
type: str |
| 475 |
host_group_id: |
| 476 |
description: |
| 477 |
- The Host Group ID. |
| 478 |
- Sample as C(/subscriptions/{subscriptionId}/resourceGroups/{RG_Name}/providers/Microsoft.Compute/hostGroups/{hostGroupName) |
| 479 |
type: str |
| 480 |
pod_subnet_id: |
| 481 |
description: |
| 482 |
- If omitted, pod IPs are statically assigned on the node subnet. |
| 483 |
type: str |
| 484 |
windows_profile: |
| 485 |
description: |
| 486 |
- The Windows agent pool's specific profile. |
| 487 |
type: dict |
| 488 |
suboptions: |
| 489 |
disable_outbound_nat: |
| 490 |
description: |
| 491 |
- The default value is C(false). |
| 492 |
- Outbound NAT can only be disabled if the cluster outboundType is NAT Gateway. |
| 493 |
- The Windows agent pool does not have node public IP enabled. |
| 494 |
type: bool |
| 495 |
network_profile: |
| 496 |
description: |
| 497 |
- Network-related settings of an agent pool. |
| 498 |
type: dict |
| 499 |
suboptions: |
| 500 |
node_public_ip_tags: |
| 501 |
description: |
| 502 |
- IPTags of instance-level public IPs. |
| 503 |
type: list |
| 504 |
elements: dict |
| 505 |
suboptions: |
| 506 |
ip_tag_type: |
| 507 |
description: |
| 508 |
- The IP tag type. Example as C(RoutingPreference). |
| 509 |
type: str |
| 510 |
tag: |
| 511 |
description: |
| 512 |
- The value of the IP tag associated with the public IP. Sample as C(Internet). |
| 513 |
type: str |
| 514 |
allowed_host_ports: |
| 515 |
description: |
| 516 |
- The port ranges that are allowed to access. |
| 517 |
- The specified ranges are allowed to overlap. |
| 518 |
type: list |
| 519 |
elements: dict |
| 520 |
suboptions: |
| 521 |
port_start: |
| 522 |
description: |
| 523 |
- The minimum port that is included in the range. |
| 524 |
- It should be ranged from C(1) to C(65535), and be less than or equal to I(port_end). |
| 525 |
type: int |
| 526 |
port_end: |
| 527 |
description: |
| 528 |
- The maximum port that is included in the range. |
| 529 |
- It should be ranged from C(1) to C(65535), and be greater than or equal to I(port_start). |
| 530 |
type: int |
| 531 |
protocol: |
| 532 |
description: |
| 533 |
- The network protocol of the port. |
| 534 |
type: str |
| 535 |
choices: |
| 536 |
- UDP |
| 537 |
- TCP |
| 538 |
application_security_groups: |
| 539 |
description: |
| 540 |
- The IDs of the application security groups which agent pool will associate when created. |
| 541 |
type: list |
| 542 |
elements: str |
| 543 |
state: |
| 544 |
description: |
| 545 |
- State of the automation runbook. Use C(present) to create or update a automation runbook and use C(absent) to delete. |
| 546 |
type: str |
| 547 |
default: present |
| 548 |
choices: |
| 549 |
- present |
| 550 |
- absent |
| 551 |
|
| 552 |
extends_documentation_fragment: |
| 553 |
- azure.azcollection.azure |
| 554 |
- azure.azcollection.azure_tags |
| 555 |
|
| 556 |
author: |
| 557 |
- xuzhang3 (@xuzhang3) |
| 558 |
- Fred Sun (@Fred-sun) |
| 559 |
|
| 560 |
''' |
| 561 |
|
| 562 |
EXAMPLES = ''' |
| 563 |
- name: Add new node agent pool |
| 564 |
azure_rm_aksagentpool: |
| 565 |
resource_group: "{{ resource_group }}" |
| 566 |
cluster_name: aksfred01 |
| 567 |
name: default-new |
| 568 |
count: 2 |
| 569 |
vm_size: Standard_B2s |
| 570 |
type_properties_type: VirtualMachineScaleSets |
| 571 |
mode: System |
| 572 |
node_labels: {"release":"stable"} |
| 573 |
max_pods: 42 |
| 574 |
orchestrator_version: 1.23.5 |
| 575 |
availability_zones: |
| 576 |
- 1 |
| 577 |
- 2 |
| 578 |
- name: Create a node agent pool with custom config |
| 579 |
azure_rm_aksagentpool: |
| 580 |
resource_group: "{{ resource_group }}" |
| 581 |
cluster_name: "min{{ rpfx }}" |
| 582 |
name: default-new2 |
| 583 |
count: 1 |
| 584 |
vm_size: Standard_B2s |
| 585 |
type_properties_type: VirtualMachineScaleSets |
| 586 |
mode: System |
| 587 |
node_labels: {"release":"stable"} |
| 588 |
max_pods: 42 |
| 589 |
enable_auto_scaling: true |
| 590 |
min_count: 1 |
| 591 |
max_count: 10 |
| 592 |
orchestrator_version: 1.23.5 |
| 593 |
availability_zones: |
| 594 |
- 1 |
| 595 |
kubelet_config: |
| 596 |
cpu_manager_policy: static |
| 597 |
cpu_cfs_quota: true |
| 598 |
fail_swap_on: false |
| 599 |
linux_os_config: |
| 600 |
transparent_huge_page_enabled: madvise |
| 601 |
swap_file_size_mb: 1500 |
| 602 |
transparent_huge_page_defrag: defer+madvise |
| 603 |
- name: Delete node agent pool |
| 604 |
azure_rm_aksagentpool: |
| 605 |
resource_group: "{{ resource_group }}" |
| 606 |
cluster_name: aksfred01 |
| 607 |
name: default-new |
| 608 |
''' |
| 609 |
|
| 610 |
RETURN = ''' |
| 611 |
aks_agent_pools: |
| 612 |
description: |
| 613 |
- Details for a node pool in the managed Kubernetes cluster. |
| 614 |
returned: always |
| 615 |
type: complex |
| 616 |
contains: |
| 617 |
id: |
| 618 |
description: |
| 619 |
- Resource ID. |
| 620 |
type: str |
| 621 |
returned: always |
| 622 |
sample: "/subscriptions/xxx-xxxf/resourcegroups/myRG/providers/Microsoft.ContainerService/managedClusters/cluster/agentPools/default" |
| 623 |
resource_group: |
| 624 |
description: |
| 625 |
- Resource group name. |
| 626 |
type: str |
| 627 |
returned: always |
| 628 |
sample: myRG |
| 629 |
name: |
| 630 |
description: |
| 631 |
- Resource name. |
| 632 |
type: str |
| 633 |
returned: always |
| 634 |
sample: default |
| 635 |
cluster_name: |
| 636 |
description: |
| 637 |
- The cluster name. |
| 638 |
type: str |
| 639 |
returned: always |
| 640 |
sample: testcluster |
| 641 |
availability_zones: |
| 642 |
description: |
| 643 |
- Availability zones for nodes. Must use VirtualMachineScaleSets AgentPoolType. |
| 644 |
type: list |
| 645 |
returned: always |
| 646 |
sample: [1, 2] |
| 647 |
count: |
| 648 |
description: |
| 649 |
- Number of agents (VMs) to host docker containers. |
| 650 |
type: int |
| 651 |
returned: always |
| 652 |
sample: 2 |
| 653 |
enable_auto_scaling: |
| 654 |
description: |
| 655 |
- Whether to enable auto-scaler. |
| 656 |
type: str |
| 657 |
returned: always |
| 658 |
sample: null |
| 659 |
enable_node_public_ip: |
| 660 |
description: |
| 661 |
- Enable public IP for nodes. |
| 662 |
type: str |
| 663 |
returned: always |
| 664 |
sample: bool |
| 665 |
max_count: |
| 666 |
description: |
| 667 |
- Maximum number of nodes for auto-scaling. |
| 668 |
type: int |
| 669 |
returned: always |
| 670 |
sample: 10 |
| 671 |
min_count: |
| 672 |
description: |
| 673 |
- Minimum number of nodes for auto-scaling. |
| 674 |
type: int |
| 675 |
returned: always |
| 676 |
sample: 1 |
| 677 |
max_pods: |
| 678 |
description: |
| 679 |
- Maximum number of pods that can run on a node. |
| 680 |
type: int |
| 681 |
returned: always |
| 682 |
sample: 42 |
| 683 |
mode: |
| 684 |
description: |
| 685 |
- AgentPoolMode represents mode of an agent pool. |
| 686 |
type: str |
| 687 |
returned: always |
| 688 |
sample: System |
| 689 |
node_image_version: |
| 690 |
description: |
| 691 |
- Version of node image. |
| 692 |
type: str |
| 693 |
returned: always |
| 694 |
sample: AKSUbuntu-1804gen2containerd-2022.08.23 |
| 695 |
node_labels: |
| 696 |
description: |
| 697 |
- Agent pool node labels to be persisted across all nodes in agent pool. |
| 698 |
type: list |
| 699 |
returned: always |
| 700 |
sample: ["release": "stable"] |
| 701 |
node_taints: |
| 702 |
description: |
| 703 |
- Taints added to new nodes during node pool create and scale. |
| 704 |
type: list |
| 705 |
returned: always |
| 706 |
sample: ["CriticalAddonsOnly=false:NoSchedule"] |
| 707 |
orchestrator_version: |
| 708 |
description: |
| 709 |
- Version of orchestrator specified when creating the managed cluster. |
| 710 |
type: str |
| 711 |
returned: always |
| 712 |
sample: 1.22.11 |
| 713 |
os_disk_size_gb: |
| 714 |
description: |
| 715 |
- OS Disk Size in GB to be used to specify the disk size for every machine in this master/agent pool. |
| 716 |
type: int |
| 717 |
returned: always |
| 718 |
sample: 128 |
| 719 |
os_type: |
| 720 |
description: |
| 721 |
- OsType to be used to specify os type. |
| 722 |
type: str |
| 723 |
returned: always |
| 724 |
sample: Linux |
| 725 |
provisioning_state: |
| 726 |
description: |
| 727 |
- The current deployment or provisioning state, which only appears in the response. |
| 728 |
type: str |
| 729 |
returned: always |
| 730 |
sample: Succeeded |
| 731 |
scale_set_eviction_policy: |
| 732 |
description: |
| 733 |
- ScaleSetEvictionPolicy to be used to specify eviction policy for Spot virtual machine scale set. |
| 734 |
type: str |
| 735 |
returned: always |
| 736 |
sample: null |
| 737 |
scale_set_priority: |
| 738 |
description: |
| 739 |
- caleSetPriority to be used to specify virtual machine scale set priority. |
| 740 |
type: str |
| 741 |
returned: always |
| 742 |
sample: null |
| 743 |
spot_max_price: |
| 744 |
description: |
| 745 |
- SpotMaxPrice to be used to specify the maximum price you are willing to pay in US Dollars. |
| 746 |
type: float |
| 747 |
returned: always |
| 748 |
sample: null |
| 749 |
security_profile: |
| 750 |
description: |
| 751 |
- The security settings of an agent pool. |
| 752 |
type: complex |
| 753 |
contains: |
| 754 |
enable_secure_boot: |
| 755 |
description: |
| 756 |
- The secure boot is disabled or enabled. |
| 757 |
type: bool |
| 758 |
returned: always |
| 759 |
sample: true |
| 760 |
enable_vtpm: |
| 761 |
description: |
| 762 |
- The vTPM is enabled or disabled. |
| 763 |
type: bool |
| 764 |
returned: always |
| 765 |
sample: true |
| 766 |
type: |
| 767 |
description: |
| 768 |
- Resource Type. |
| 769 |
type: str |
| 770 |
returned: always |
| 771 |
sample: Microsoft.ContainerService/managedClusters/agentPools |
| 772 |
type_properties_type: |
| 773 |
description: |
| 774 |
- AgentPoolType represents types of an agent pool. |
| 775 |
type: str |
| 776 |
returned: always |
| 777 |
sample: VirtualMachineScaleSets |
| 778 |
upgrade_settings: |
| 779 |
description: |
| 780 |
- Settings for upgrading the agentpool. |
| 781 |
type: str |
| 782 |
returned: always |
| 783 |
sample: null |
| 784 |
vm_size: |
| 785 |
description: |
| 786 |
- Size of agent VMs. |
| 787 |
type: str |
| 788 |
returned: always |
| 789 |
sample: Standard_B2s |
| 790 |
vnet_subnet_id: |
| 791 |
description: |
| 792 |
- VNet SubnetID specifies the VNet's subnet identifier. |
| 793 |
type: str |
| 794 |
returned: always |
| 795 |
sample: null |
| 796 |
kubelet_config: |
| 797 |
description: |
| 798 |
- The Kubelet configuration on the agent pool nodes. |
| 799 |
type: dict |
| 800 |
returned: always |
| 801 |
sample: { |
| 802 |
cpu_cfs_quota: true, |
| 803 |
cpu_cfs_quota_period: 100ms, |
| 804 |
cpu_manager_policy: static, |
| 805 |
fail_swap_on: false, |
| 806 |
image_gc_high_threshold: 85, |
| 807 |
image_gc_low_threshold: 80, |
| 808 |
topology_manager_policy: none |
| 809 |
} |
| 810 |
linux_os_config: |
| 811 |
description: |
| 812 |
- The OS configuration of Linux agent nodes. |
| 813 |
type: dict |
| 814 |
returned: always |
| 815 |
sample: { |
| 816 |
swap_file_size_mb: 1500, |
| 817 |
sysctls: {}, |
| 818 |
transparent_huge_page_defrag: defer+madvise, |
| 819 |
transparent_huge_page_enabled: madvise |
| 820 |
} |
| 821 |
power_state: |
| 822 |
description: |
| 823 |
- The agent pool's power state. |
| 824 |
type: dict |
| 825 |
returned: always |
| 826 |
sample: {code: Running} |
| 827 |
os_sku: |
| 828 |
description: |
| 829 |
- The node agent pool's SKU. |
| 830 |
type: str |
| 831 |
returned: always |
| 832 |
sample: Ubuntu |
| 833 |
tags: |
| 834 |
description: |
| 835 |
- The tags of the node agent pool. |
| 836 |
type: dict |
| 837 |
returned: always |
| 838 |
sample: {key1: value1, key2: value2} |
| 839 |
kubelet_disk_type: |
| 840 |
description: |
| 841 |
- Determines the placement of emptyDir volumes, container runtime data root, and Kubelet ephemeral storage. |
| 842 |
type: str |
| 843 |
returned: always |
| 844 |
sample: OS |
| 845 |
workload_runtime: |
| 846 |
description: |
| 847 |
- Determines the type of workload a node can run. |
| 848 |
type: str |
| 849 |
returned: always |
| 850 |
sample: OCIContainer |
| 851 |
scale_down_mode: |
| 852 |
description: |
| 853 |
- This also effects the cluster autoscaler behavior. |
| 854 |
type: str |
| 855 |
returned: always |
| 856 |
sample: Delete |
| 857 |
node_public_ip_prefix_id: |
| 858 |
description: |
| 859 |
- The Azure Public IP prefix's ID. |
| 860 |
type: str |
| 861 |
returned: always |
| 862 |
sample: null |
| 863 |
proximity_placement_group_id: |
| 864 |
description: |
| 865 |
- The ID for Proximity Placement Group. |
| 866 |
type: str |
| 867 |
returned: always |
| 868 |
sample: /subscriptions/xxx-xxx/resourceGroups/myRG/providers/Microsoft.Compute/proximityPlacementGroups/proxi01 |
| 869 |
enable_encryption_at_host: |
| 870 |
description: |
| 871 |
- This is only supported on certain VM sizes and in certain Azure regions. |
| 872 |
type: bool |
| 873 |
returned: always |
| 874 |
sample: false |
| 875 |
enable_ultra_ssd: |
| 876 |
description: |
| 877 |
- Whether enable FIPS node pool. |
| 878 |
type: bool |
| 879 |
returned: always |
| 880 |
sample: false |
| 881 |
gpu_instance_profile: |
| 882 |
description: |
| 883 |
- GPUInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU. |
| 884 |
type: str |
| 885 |
returned: always |
| 886 |
sample: MIG1g |
| 887 |
windows_profile: |
| 888 |
description: |
| 889 |
- The Windows agent pool's specific profile. |
| 890 |
type: dict |
| 891 |
returned: when-used |
| 892 |
sample: {"disable_outbound_nat": false} |
| 893 |
network_profile: |
| 894 |
description: |
| 895 |
- Network-related settings of an agent pool. |
| 896 |
type: complex |
| 897 |
returned: when-used |
| 898 |
contains: |
| 899 |
allowed_host_ports: |
| 900 |
description: |
| 901 |
- The port ranges that are allowed to access. |
| 902 |
type: list |
| 903 |
returned: always |
| 904 |
sample: [{"port_end": 200, "port_start": 10, "protocol": "TCP"}] |
| 905 |
application_security_groups: |
| 906 |
description: |
| 907 |
- The IDs of the application security groups which agent pool will associate when created. |
| 908 |
type: list |
| 909 |
returned: always |
| 910 |
sample: ["/subscriptions/xxxxxx/resourceGroups/testRG/providers/Microsoft.Network/applicationSecurityGroups/appnsg"] |
| 911 |
pod_subnet_id: |
| 912 |
description: |
| 913 |
- The subnet ID. |
| 914 |
type: str |
| 915 |
returned: always |
| 916 |
sample: "/subscriptions/xxxx/resourceGroups/testRG/providers/Microsoft.Network/virtualNetworks/My_Virtual_Network/subnets/foobar" |
| 917 |
host_group_id: |
| 918 |
description: |
| 919 |
- The host group ID. |
| 920 |
type: str |
| 921 |
returned: always |
| 922 |
sample: "/subscriptions/xxxxx/resourceGroups/testRG/providers/Microsoft.Compute/hostGroups/hostgroup" |
| 923 |
capacity_reservation_group_id: |
| 924 |
description: |
| 925 |
- The ID of Capacity Reservation Group. |
| 926 |
returned: always |
| 927 |
type: str |
| 928 |
sample: "/subscriptions/xxxxx/resourceGroups/testRG/providers/Microsoft.Compute/capacityReservationGroups/crgid" |
| 929 |
os_disk_type: |
| 930 |
description: |
| 931 |
- The type of the OS disk. |
| 932 |
returned: always |
| 933 |
sample: Managed |
| 934 |
type: str |
| 935 |
''' |
| 936 |
|
| 937 |
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common_ext import AzureRMModuleBaseExt |
| 938 |
|
| 939 |
try: |
| 940 |
from azure.core.exceptions import ResourceNotFoundError |
| 941 |
from azure.core.polling import LROPoller |
| 942 |
except ImportError: |
| 943 |
pass |
| 944 |
|
| 945 |
|
| 946 |
class AzureRMAksAgentPool(AzureRMModuleBaseExt): |
| 947 |
def __init__(self): |
| 948 |
|
| 949 |
self.module_arg_spec = dict( |
| 950 |
resource_group=dict( |
| 951 |
type='str', |
| 952 |
required=True |
| 953 |
), |
| 954 |
name=dict( |
| 955 |
type='str', |
| 956 |
required=True |
| 957 |
), |
| 958 |
cluster_name=dict( |
| 959 |
type='str', |
| 960 |
required=True |
| 961 |
), |
| 962 |
count=dict( |
| 963 |
type='int', |
| 964 |
), |
| 965 |
vm_size=dict( |
| 966 |
type='str', |
| 967 |
), |
| 968 |
os_disk_size_gb=dict( |
| 969 |
type='int' |
| 970 |
), |
| 971 |
vnet_subnet_id=dict( |
| 972 |
type='str' |
| 973 |
), |
| 974 |
availability_zones=dict( |
| 975 |
type='list', |
| 976 |
elements='int', |
| 977 |
choices=[1, 2, 3] |
| 978 |
), |
| 979 |
os_type=dict( |
| 980 |
type='str', |
| 981 |
choices=['Linux', 'Windows', 'linux', 'windows'] |
| 982 |
), |
| 983 |
orchestrator_version=dict( |
| 984 |
type='str', |
| 985 |
), |
| 986 |
type_properties_type=dict( |
| 987 |
type='str', |
| 988 |
choices=['VirtualMachineScaleSets', 'AvailabilitySet'] |
| 989 |
), |
| 990 |
mode=dict( |
| 991 |
type='str', |
| 992 |
choices=['System', 'User'], |
| 993 |
), |
| 994 |
enable_auto_scaling=dict( |
| 995 |
type='bool' |
| 996 |
), |
| 997 |
max_count=dict( |
| 998 |
type='int' |
| 999 |
), |
| 1000 |
node_labels=dict( |
| 1001 |
type='dict' |
| 1002 |
), |
| 1003 |
node_taints=dict( |
| 1004 |
type='list', |
| 1005 |
elements='str' |
| 1006 |
), |
| 1007 |
min_count=dict( |
| 1008 |
type='int' |
| 1009 |
), |
| 1010 |
max_pods=dict( |
| 1011 |
type='int' |
| 1012 |
), |
| 1013 |
kubelet_disk_type=dict( |
| 1014 |
type='str', choices=['OS', 'Temporary'] |
| 1015 |
), |
| 1016 |
workload_runtime=dict( |
| 1017 |
type='str', choices=['OCIContainer', 'WasmWasi'] |
| 1018 |
), |
| 1019 |
os_sku=dict( |
| 1020 |
type='str', choices=["Ubuntu", "AzureLinux", "Windows2022", "Windows2019"] |
| 1021 |
), |
| 1022 |
scale_down_mode=dict( |
| 1023 |
type='str', |
| 1024 |
choices=['Delete', 'Deallocate'], |
| 1025 |
default='Delete' |
| 1026 |
), |
| 1027 |
upgrade_settings=dict( |
| 1028 |
type='dict', |
| 1029 |
options=dict( |
| 1030 |
max_surge=dict( |
| 1031 |
type='str' |
| 1032 |
) |
| 1033 |
) |
| 1034 |
), |
| 1035 |
power_state=dict( |
| 1036 |
type='dict', |
| 1037 |
options=dict( |
| 1038 |
code=dict( |
| 1039 |
type='str', |
| 1040 |
choices=['Running', 'Stopped'] |
| 1041 |
) |
| 1042 |
) |
| 1043 |
), |
| 1044 |
enable_node_public_ip=dict( |
| 1045 |
type='bool' |
| 1046 |
), |
| 1047 |
scale_set_priority=dict( |
| 1048 |
type='str', |
| 1049 |
choices=["Spot", "Regular"], |
| 1050 |
), |
| 1051 |
node_public_ip_prefix_id=dict( |
| 1052 |
type='str' |
| 1053 |
), |
| 1054 |
scale_set_eviction_policy=dict( |
| 1055 |
type='str', |
| 1056 |
choices=['Delete', 'Deallocate'], |
| 1057 |
), |
| 1058 |
spot_max_price=dict( |
| 1059 |
type='float' |
| 1060 |
), |
| 1061 |
proximity_placement_group_id=dict( |
| 1062 |
type='str' |
| 1063 |
), |
| 1064 |
kubelet_config=dict( |
| 1065 |
type='dict', |
| 1066 |
options=dict( |
| 1067 |
cpu_manager_policy=dict(type='str', choices=['none', 'static'], default='none'), |
| 1068 |
cpu_cfs_quota=dict(type='bool', default='true'), |
| 1069 |
cpu_cfs_quota_period=dict(type='str', default='100ms'), |
| 1070 |
image_gc_high_threshold=dict(type='int', default=85), |
| 1071 |
image_gc_low_threshold=dict(type='int', default=80), |
| 1072 |
topology_manager_policy=dict( |
| 1073 |
type='str', |
| 1074 |
default='none', |
| 1075 |
choices=['none', 'best-effort', 'restricted', 'single-numa-node'] |
| 1076 |
), |
| 1077 |
allowed_unsafe_sysctls=dict( |
| 1078 |
type='list', |
| 1079 |
elements='str' |
| 1080 |
), |
| 1081 |
fail_swap_on=dict(type='bool'), |
| 1082 |
container_log_max_size_mb=dict(type='int'), |
| 1083 |
container_log_max_files=dict(type='int'), |
| 1084 |
pod_max_pids=dict(type='int') |
| 1085 |
) |
| 1086 |
), |
| 1087 |
linux_os_config=dict( |
| 1088 |
type='dict', |
| 1089 |
options=dict( |
| 1090 |
sysctls=dict( |
| 1091 |
type='dict', |
| 1092 |
options=dict( |
| 1093 |
net_core_somaxconn=dict(type='int'), |
| 1094 |
net_core_netdev_max_backlog=dict(type='int'), |
| 1095 |
net_core_rmem_default=dict(type='int'), |
| 1096 |
net_core_rmem_max=dict(type='int'), |
| 1097 |
net_core_wmem_default=dict(type='int'), |
| 1098 |
net_core_wmem_max=dict(type='int'), |
| 1099 |
net_core_optmem_max=dict(type='int'), |
| 1100 |
net_ipv4_tcp_max_syn_backlog=dict(type='int'), |
| 1101 |
net_ipv4_tcp_max_tw_buckets=dict(type='int'), |
| 1102 |
net_ipv4_tcp_fin_timeout=dict(type='int'), |
| 1103 |
net_ipv4_tcp_keepalive_time=dict(type='int'), |
| 1104 |
net_ipv4_tcp_keepalive_probes=dict(type='int'), |
| 1105 |
net_ipv4_tcpkeepalive_intvl=dict(type='int'), |
| 1106 |
net_ipv4_tcp_tw_reuse=dict(type='bool'), |
| 1107 |
net_ipv4_ip_local_port_range=dict(type='str'), |
| 1108 |
net_ipv4_neigh_default_gc_thresh1=dict(type='int'), |
| 1109 |
net_ipv4_neigh_default_gc_thresh2=dict(type='int'), |
| 1110 |
net_ipv4_neigh_default_gc_thresh3=dict(type='int'), |
| 1111 |
net_netfilter_nf_conntrack_max=dict(type='int'), |
| 1112 |
net_netfilter_nf_conntrack_buckets=dict(type='int'), |
| 1113 |
fs_inotify_max_user_watches=dict(type='int'), |
| 1114 |
fs_file_max=dict(type='int'), |
| 1115 |
fs_aio_max_nr=dict(type='int'), |
| 1116 |
fs_nr_open=dict(type='int'), |
| 1117 |
kernel_threads_max=dict(type='int'), |
| 1118 |
vm_max_map_count=dict(type='int'), |
| 1119 |
vm_swappiness=dict(type='int'), |
| 1120 |
vm_vfs_cache_pressure=dict(type='int') |
| 1121 |
) |
| 1122 |
), |
| 1123 |
transparent_huge_page_enabled=dict( |
| 1124 |
type='str', |
| 1125 |
choices=['always', 'madvise', 'never'], |
| 1126 |
default='always' |
| 1127 |
), |
| 1128 |
swap_file_size_mb=dict( |
| 1129 |
type='int' |
| 1130 |
), |
| 1131 |
transparent_huge_page_defrag=dict( |
| 1132 |
type='str', |
| 1133 |
default='madvise', |
| 1134 |
choices=['always', 'defer', 'defer+madvise', 'madvise', 'never'] |
| 1135 |
) |
| 1136 |
) |
| 1137 |
), |
| 1138 |
enable_encryption_at_host=dict( |
| 1139 |
type='bool' |
| 1140 |
), |
| 1141 |
enable_ultra_ssd=dict( |
| 1142 |
type='bool' |
| 1143 |
), |
| 1144 |
enable_fips=dict( |
| 1145 |
type='bool' |
| 1146 |
), |
| 1147 |
gpu_instance_profile=dict( |
| 1148 |
type='str', |
| 1149 |
choices=["MIG1g", "MIG2g", "MIG3g", "MIG4g", "MIG7g"] |
| 1150 |
), |
| 1151 |
security_profile=dict( |
| 1152 |
type='dict', |
| 1153 |
options=dict( |
| 1154 |
enable_secure_boot=dict(type='bool', default=False), |
| 1155 |
enable_vtpm=dict(type='bool', default=False) |
| 1156 |
) |
| 1157 |
), |
| 1158 |
os_disk_type=dict( |
| 1159 |
type='str', |
| 1160 |
choices=['Managed', 'Ephemeral'] |
| 1161 |
), |
| 1162 |
capacity_reservation_group_id=dict( |
| 1163 |
type='str', |
| 1164 |
), |
| 1165 |
host_group_id=dict( |
| 1166 |
type='str', |
| 1167 |
), |
| 1168 |
pod_subnet_id=dict( |
| 1169 |
type='str', |
| 1170 |
), |
| 1171 |
network_profile=dict( |
| 1172 |
type='dict', |
| 1173 |
options=dict( |
| 1174 |
node_public_ip_tags=dict( |
| 1175 |
type='list', |
| 1176 |
elements='dict', |
| 1177 |
options=dict( |
| 1178 |
ip_tag_type=dict(type='str'), |
| 1179 |
tag=dict(type='str') |
| 1180 |
) |
| 1181 |
), |
| 1182 |
allowed_host_ports=dict( |
| 1183 |
type='list', |
| 1184 |
elements='dict', |
| 1185 |
options=dict( |
| 1186 |
port_start=dict(type='int'), |
| 1187 |
port_end=dict(type='int'), |
| 1188 |
protocol=dict( |
| 1189 |
type='str', |
| 1190 |
choices=['UDP', 'TCP'] |
| 1191 |
) |
| 1192 |
) |
| 1193 |
), |
| 1194 |
application_security_groups=dict( |
| 1195 |
type='list', |
| 1196 |
elements='str' |
| 1197 |
) |
| 1198 |
) |
| 1199 |
), |
| 1200 |
windows_profile=dict( |
| 1201 |
type='dict', |
| 1202 |
options=dict( |
| 1203 |
disable_outbound_nat=dict(type='bool') |
| 1204 |
) |
| 1205 |
), |
| 1206 |
state=dict( |
| 1207 |
type='str', |
| 1208 |
choices=['present', 'absent'], |
| 1209 |
default='present' |
| 1210 |
) |
| 1211 |
) |
| 1212 |
|
| 1213 |
self.results = dict() |
| 1214 |
self.resource_group = None |
| 1215 |
self.name = None |
| 1216 |
self.cluster_name = None |
| 1217 |
self.count = None |
| 1218 |
self.vm_size = None |
| 1219 |
self.mode = None |
| 1220 |
self.os_disk_size_gb = None |
| 1221 |
self.storage_profiles = None |
| 1222 |
self.vnet_subnet_id = None |
| 1223 |
self.availability_zones = None |
| 1224 |
self.os_type = None |
| 1225 |
self.orchestrator_version = None |
| 1226 |
self.type_properties_type = None |
| 1227 |
self.enable_auto_scaling = None |
| 1228 |
self.max_count = None |
| 1229 |
self.node_labels = None |
| 1230 |
self.node_taints = None |
| 1231 |
self.min_count = None |
| 1232 |
self.max_pods = None |
| 1233 |
self.tags = None |
| 1234 |
self.kubelet_disk_type = None |
| 1235 |
self.workload_runtime = None |
| 1236 |
self.os_sku = None |
| 1237 |
self.scale_down_mode = None |
| 1238 |
self.upgrade_settings = None |
| 1239 |
self.power_state = None |
| 1240 |
self.enable_node_public_ip = None |
| 1241 |
self.scale_set_priority = None |
| 1242 |
self.node_public_ip_prefix_id = None |
| 1243 |
self.scale_set_eviction_policy = None |
| 1244 |
self.spot_max_price = None |
| 1245 |
self.proximity_placement_group_id = None |
| 1246 |
self.kubelet_config = None |
| 1247 |
self.linux_os_config = None |
| 1248 |
self.enable_encryption_at_host = None |
| 1249 |
self.enable_ultra_ssd = None |
| 1250 |
self.enable_fips = None |
| 1251 |
self.gpu_instance_profile = None |
| 1252 |
self.security_profile = None |
| 1253 |
self.os_disk_type = None |
| 1254 |
self.capacity_reservation_group_id = None |
| 1255 |
self.host_group_id = None |
| 1256 |
self.pod_subnet_id = None |
| 1257 |
self.network_profile = None |
| 1258 |
self.windows_profile = None |
| 1259 |
self.body = dict() |
| 1260 |
|
| 1261 |
super(AzureRMAksAgentPool, self).__init__(self.module_arg_spec, supports_check_mode=True, supports_tags=True) |
| 1262 |
|
| 1263 |
def exec_module(self, **kwargs): |
| 1264 |
|
| 1265 |
for key in list(self.module_arg_spec) + ['tags']: |
| 1266 |
setattr(self, key, kwargs[key]) |
| 1267 |
if key not in ['resource_group', 'cluster_name', 'name', 'state']: |
| 1268 |
self.body[key] = kwargs[key] |
| 1269 |
|
| 1270 |
agent_pool = self.get() |
| 1271 |
changed = False |
| 1272 |
response = None |
| 1273 |
|
| 1274 |
if self.state == 'present': |
| 1275 |
if agent_pool: |
| 1276 |
update_tags, self.body['tags'] = self.update_tags(agent_pool.get('tags')) |
| 1277 |
for key in self.body.keys(): |
| 1278 |
if key == 'tags': |
| 1279 |
if update_tags: |
| 1280 |
changed = True |
| 1281 |
elif self.body[key] is not None and isinstance(self.body[key], dict): |
| 1282 |
for item in self.body[key].keys(): |
| 1283 |
if key == 'security_profile': |
| 1284 |
if bool(self.body[key][item]) != bool(agent_pool[key].get(item)): |
| 1285 |
changed = True |
| 1286 |
elif key == 'windows_profile': |
| 1287 |
if agent_pool.get(key) is None or bool(self.body[key][item]) != bool(agent_pool[key].get(item)): |
| 1288 |
changed = True |
| 1289 |
elif not self.default_compare({}, self.body[key], agent_pool[key], '', dict(compare=[])): |
| 1290 |
changed = True |
| 1291 |
elif key == 'node_public_ip_prefix_id': |
| 1292 |
pass |
| 1293 |
elif key == 'node_taints' and self.body[key] is not None: |
| 1294 |
if len(self.body[key]) != len(agent_pool[key]) or (not all(item in agent_pool[key] for item in self.body[key])): |
| 1295 |
changed = True |
| 1296 |
elif self.body[key] is not None and self.body[key] != agent_pool[key] and key not in ['scale_set_priority', 'spot_max_price']: |
| 1297 |
changed = True |
| 1298 |
else: |
| 1299 |
self.body[key] = agent_pool[key] |
| 1300 |
else: |
| 1301 |
changed = True |
| 1302 |
|
| 1303 |
if changed: |
| 1304 |
if not self.check_mode: |
| 1305 |
response = self.create_or_update(self.body) |
| 1306 |
|
| 1307 |
else: |
| 1308 |
if not self.check_mode: |
| 1309 |
if agent_pool: |
| 1310 |
response = self.delete_agentpool() |
| 1311 |
changed = True |
| 1312 |
else: |
| 1313 |
changed = False |
| 1314 |
else: |
| 1315 |
changed = True |
| 1316 |
|
| 1317 |
self.results['changed'] = changed |
| 1318 |
self.results['aks_agent_pools'] = response |
| 1319 |
return self.results |
| 1320 |
|
| 1321 |
def get(self): |
| 1322 |
try: |
| 1323 |
response = self.managedcluster_client.agent_pools.get(self.resource_group, self.cluster_name, self.name) |
| 1324 |
return self.to_dict(response) |
| 1325 |
except ResourceNotFoundError: |
| 1326 |
pass |
| 1327 |
|
| 1328 |
def create_or_update(self, parameters): |
| 1329 |
try: |
| 1330 |
response = self.managedcluster_client.agent_pools.begin_create_or_update(self.resource_group, self.cluster_name, self.name, parameters) |
| 1331 |
if isinstance(response, LROPoller): |
| 1332 |
response = self.get_poller_result(response) |
| 1333 |
return self.to_dict(response) |
| 1334 |
except Exception as exc: |
| 1335 |
self.fail('Error when creating cluster node agent pool {0}: {1}'.format(self.name, exc)) |
| 1336 |
|
| 1337 |
def delete_agentpool(self): |
| 1338 |
try: |
| 1339 |
self.managedcluster_client.agent_pools.begin_delete(self.resource_group, self.cluster_name, self.name) |
| 1340 |
except Exception as exc: |
| 1341 |
self.fail('Error when deleting cluster agent pool {0}: {1}'.format(self.name, exc)) |
| 1342 |
|
| 1343 |
def to_dict(self, agent_pool): |
| 1344 |
if not agent_pool: |
| 1345 |
return None |
| 1346 |
agent_pool_dict = dict( |
| 1347 |
resource_group=self.resource_group, |
| 1348 |
cluster_name=self.cluster_name, |
| 1349 |
id=agent_pool.id, |
| 1350 |
type=agent_pool.type, |
| 1351 |
name=agent_pool.name, |
| 1352 |
count=agent_pool.count, |
| 1353 |
vm_size=agent_pool.vm_size, |
| 1354 |
os_disk_size_gb=agent_pool.os_disk_size_gb, |
| 1355 |
vnet_subnet_id=agent_pool.vnet_subnet_id, |
| 1356 |
max_pods=agent_pool.max_pods, |
| 1357 |
os_type=agent_pool.os_type, |
| 1358 |
max_count=agent_pool.max_count, |
| 1359 |
min_count=agent_pool.min_count, |
| 1360 |
enable_auto_scaling=agent_pool.enable_auto_scaling, |
| 1361 |
type_properties_type=agent_pool.type_properties_type, |
| 1362 |
mode=agent_pool.mode, |
| 1363 |
orchestrator_version=agent_pool.orchestrator_version, |
| 1364 |
node_image_version=agent_pool.node_image_version, |
| 1365 |
upgrade_settings=dict(), |
| 1366 |
provisioning_state=agent_pool.provisioning_state, |
| 1367 |
availability_zones=[], |
| 1368 |
enable_node_public_ip=agent_pool.enable_node_public_ip, |
| 1369 |
scale_set_priority=agent_pool.scale_set_priority, |
| 1370 |
scale_set_eviction_policy=agent_pool.scale_set_eviction_policy, |
| 1371 |
spot_max_price=agent_pool.spot_max_price, |
| 1372 |
node_labels=agent_pool.node_labels, |
| 1373 |
node_taints=agent_pool.node_taints if agent_pool.node_taints else [], |
| 1374 |
tags=agent_pool.tags, |
| 1375 |
kubelet_disk_type=agent_pool.kubelet_disk_type, |
| 1376 |
workload_runtime=agent_pool.workload_runtime, |
| 1377 |
os_sku=agent_pool.os_sku, |
| 1378 |
scale_down_mode=agent_pool.scale_down_mode, |
| 1379 |
power_state=dict(), |
| 1380 |
node_public_ip_prefix_id=agent_pool.node_public_ip_prefix_id, |
| 1381 |
proximity_placement_group_id=agent_pool.proximity_placement_group_id, |
| 1382 |
kubelet_config=dict(), |
| 1383 |
linux_os_config=dict(), |
| 1384 |
security_profile=dict(), |
| 1385 |
enable_encryption_at_host=agent_pool.enable_encryption_at_host, |
| 1386 |
enable_ultra_ssd=agent_pool.enable_ultra_ssd, |
| 1387 |
enable_fips=agent_pool.enable_fips, |
| 1388 |
gpu_instance_profile=agent_pool.gpu_instance_profile, |
| 1389 |
os_disk_type=agent_pool.os_disk_type, |
| 1390 |
capacity_reservation_group_id=agent_pool.capacity_reservation_group_id, |
| 1391 |
host_group_id=agent_pool.host_group_id, |
| 1392 |
pod_subnet_id=agent_pool.pod_subnet_id, |
| 1393 |
network_profile=dict(), |
| 1394 |
windows_profile=dict(), |
| 1395 |
) |
| 1396 |
|
| 1397 |
if agent_pool.upgrade_settings is not None: |
| 1398 |
agent_pool_dict['upgrade_settings']['max_surge'] = agent_pool.upgrade_settings.max_surge |
| 1399 |
else: |
| 1400 |
agent_pool_dict['upgrade_settings'] = None |
| 1401 |
|
| 1402 |
if agent_pool.availability_zones is not None: |
| 1403 |
for key in agent_pool.availability_zones: |
| 1404 |
agent_pool_dict['availability_zones'].append(int(key)) |
| 1405 |
else: |
| 1406 |
agent_pool_dict['availability_zones'] = None |
| 1407 |
|
| 1408 |
if agent_pool.kubelet_config is not None: |
| 1409 |
agent_pool_dict['kubelet_config'] = agent_pool.kubelet_config.as_dict() |
| 1410 |
else: |
| 1411 |
agent_pool_dict['kubelet_config'] = None |
| 1412 |
|
| 1413 |
if agent_pool.power_state is not None: |
| 1414 |
agent_pool_dict['power_state']['code'] = agent_pool.power_state.code |
| 1415 |
else: |
| 1416 |
agent_pool_dict['power_state'] = None |
| 1417 |
|
| 1418 |
if agent_pool.linux_os_config is not None: |
| 1419 |
agent_pool_dict['linux_os_config']['transparent_huge_page_enabled'] = agent_pool.linux_os_config.transparent_huge_page_enabled |
| 1420 |
agent_pool_dict['linux_os_config']['transparent_huge_page_defrag'] = agent_pool.linux_os_config.transparent_huge_page_defrag |
| 1421 |
agent_pool_dict['linux_os_config']['swap_file_size_mb'] = agent_pool.linux_os_config.swap_file_size_mb |
| 1422 |
agent_pool_dict['linux_os_config']['sysctls'] = dict() |
| 1423 |
if agent_pool.linux_os_config.sysctls is not None: |
| 1424 |
agent_pool_dict['linux_os_config']['sysctls'] = agent_pool.linux_os_config.sysctls.as_dict() |
| 1425 |
else: |
| 1426 |
agent_pool_dict['linux_os_config']['sysctls'] = None |
| 1427 |
else: |
| 1428 |
agent_pool_dict['linux_os_config'] = None |
| 1429 |
|
| 1430 |
if agent_pool.security_profile is not None: |
| 1431 |
agent_pool_dict['security_profile']['enable_vtpm'] = agent_pool.security_profile.enable_vtpm |
| 1432 |
agent_pool_dict['security_profile']['enable_secure_boot'] = agent_pool.security_profile.enable_secure_boot |
| 1433 |
else: |
| 1434 |
agent_pool_dict['security_profile'] = None |
| 1435 |
|
| 1436 |
if agent_pool.security_profile is not None: |
| 1437 |
agent_pool_dict['security_profile']['enable_vtpm'] = agent_pool.security_profile.enable_vtpm |
| 1438 |
agent_pool_dict['security_profile']['enable_secure_boot'] = agent_pool.security_profile.enable_secure_boot |
| 1439 |
else: |
| 1440 |
agent_pool_dict['security_profile'] = None |
| 1441 |
|
| 1442 |
if agent_pool.network_profile is not None: |
| 1443 |
agent_pool_dict['network_profile'] = agent_pool.network_profile.as_dict() |
| 1444 |
else: |
| 1445 |
agent_pool_dict['network_profile'] = None |
| 1446 |
|
| 1447 |
if agent_pool.windows_profile is not None: |
| 1448 |
agent_pool_dict['windows_profile']['disable_outbound_nat'] = agent_pool.windows_profile.disable_outbound_nat |
| 1449 |
else: |
| 1450 |
agent_pool_dict['windows_profile'] = None |
| 1451 |
|
| 1452 |
return agent_pool_dict |
| 1453 |
|
| 1454 |
|
| 1455 |
def main(): |
| 1456 |
AzureRMAksAgentPool() |
| 1457 |
|
| 1458 |
|
| 1459 |
if __name__ == '__main__': |
| 1460 |
main() |