| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Copyright: Ansible Project |
| 5 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 |
|
| 7 |
DOCUMENTATION = r""" |
| 8 |
--- |
| 9 |
module: ecs_taskdefinition_info |
| 10 |
version_added: 1.0.0 |
| 11 |
short_description: Describe a task definition in ECS |
| 12 |
notes: |
| 13 |
- For details of the parameters and returns see |
| 14 |
U(http://boto3.readthedocs.io/en/latest/reference/services/ecs.html#ECS.Client.describe_task_definition) |
| 15 |
description: |
| 16 |
- Describes a task definition in ECS. |
| 17 |
author: |
| 18 |
- Gustavo Maia (@gurumaia) |
| 19 |
- Mark Chance (@Java1Guy) |
| 20 |
- Darek Kaczynski (@kaczynskid) |
| 21 |
options: |
| 22 |
task_definition: |
| 23 |
description: |
| 24 |
- The name of the task definition to get details for |
| 25 |
required: true |
| 26 |
type: str |
| 27 |
extends_documentation_fragment: |
| 28 |
- amazon.aws.common.modules |
| 29 |
- amazon.aws.region.modules |
| 30 |
- amazon.aws.boto3 |
| 31 |
""" |
| 32 |
|
| 33 |
EXAMPLES = r""" |
| 34 |
# Note: These examples do not set authentication details, see the AWS Guide for details. |
| 35 |
|
| 36 |
- community.aws.ecs_taskdefinition_info: |
| 37 |
task_definition: test-td |
| 38 |
""" |
| 39 |
|
| 40 |
RETURN = r""" |
| 41 |
container_definitions: |
| 42 |
description: Returns a list of complex objects representing the containers |
| 43 |
returned: success |
| 44 |
type: complex |
| 45 |
contains: |
| 46 |
name: |
| 47 |
description: The name of a container. |
| 48 |
returned: always |
| 49 |
type: str |
| 50 |
image: |
| 51 |
description: The image used to start a container. |
| 52 |
returned: always |
| 53 |
type: str |
| 54 |
cpu: |
| 55 |
description: The number of cpu units reserved for the container. |
| 56 |
returned: always |
| 57 |
type: int |
| 58 |
memoryReservation: |
| 59 |
description: The soft limit (in MiB) of memory to reserve for the container. |
| 60 |
returned: when present |
| 61 |
type: int |
| 62 |
links: |
| 63 |
description: Links to other containers. |
| 64 |
returned: when present |
| 65 |
type: str |
| 66 |
portMappings: |
| 67 |
description: The list of port mappings for the container. |
| 68 |
returned: always |
| 69 |
type: complex |
| 70 |
contains: |
| 71 |
containerPort: |
| 72 |
description: The port number on the container. |
| 73 |
returned: when present |
| 74 |
type: int |
| 75 |
hostPort: |
| 76 |
description: The port number on the container instance to reserve for your container. |
| 77 |
returned: when present |
| 78 |
type: int |
| 79 |
protocol: |
| 80 |
description: The protocol used for the port mapping. |
| 81 |
returned: when present |
| 82 |
type: str |
| 83 |
essential: |
| 84 |
description: Whether this is an essential container or not. |
| 85 |
returned: always |
| 86 |
type: bool |
| 87 |
entryPoint: |
| 88 |
description: The entry point that is passed to the container. |
| 89 |
returned: when present |
| 90 |
type: str |
| 91 |
command: |
| 92 |
description: The command that is passed to the container. |
| 93 |
returned: when present |
| 94 |
type: str |
| 95 |
environment: |
| 96 |
description: The environment variables to pass to a container. |
| 97 |
returned: always |
| 98 |
type: complex |
| 99 |
contains: |
| 100 |
name: |
| 101 |
description: The name of the environment variable. |
| 102 |
returned: when present |
| 103 |
type: str |
| 104 |
value: |
| 105 |
description: The value of the environment variable. |
| 106 |
returned: when present |
| 107 |
type: str |
| 108 |
mountPoints: |
| 109 |
description: The mount points for data volumes in your container. |
| 110 |
returned: always |
| 111 |
type: complex |
| 112 |
contains: |
| 113 |
sourceVolume: |
| 114 |
description: The name of the volume to mount. |
| 115 |
returned: when present |
| 116 |
type: str |
| 117 |
containerPath: |
| 118 |
description: The path on the container to mount the host volume at. |
| 119 |
returned: when present |
| 120 |
type: str |
| 121 |
readOnly: |
| 122 |
description: If this value is true , the container has read-only access to the volume. |
| 123 |
If this value is false , then the container can write to the volume. |
| 124 |
returned: when present |
| 125 |
type: bool |
| 126 |
volumesFrom: |
| 127 |
description: Data volumes to mount from another container. |
| 128 |
returned: always |
| 129 |
type: complex |
| 130 |
contains: |
| 131 |
sourceContainer: |
| 132 |
description: The name of another container within the same task definition to mount volumes from. |
| 133 |
returned: when present |
| 134 |
type: str |
| 135 |
readOnly: |
| 136 |
description: If this value is true , the container has read-only access to the volume. |
| 137 |
If this value is false , then the container can write to the volume. |
| 138 |
returned: when present |
| 139 |
type: bool |
| 140 |
hostname: |
| 141 |
description: The hostname to use for your container. |
| 142 |
returned: when present |
| 143 |
type: str |
| 144 |
user: |
| 145 |
description: The user name to use inside the container. |
| 146 |
returned: when present |
| 147 |
type: str |
| 148 |
workingDirectory: |
| 149 |
description: The working directory in which to run commands inside the container. |
| 150 |
returned: when present |
| 151 |
type: str |
| 152 |
disableNetworking: |
| 153 |
description: When this parameter is true, networking is disabled within the container. |
| 154 |
returned: when present |
| 155 |
type: bool |
| 156 |
privileged: |
| 157 |
description: When this parameter is true, the container is given elevated |
| 158 |
privileges on the host container instance (similar to the root user). |
| 159 |
returned: when present |
| 160 |
type: bool |
| 161 |
readonlyRootFilesystem: |
| 162 |
description: When this parameter is true, the container is given read-only access to its root file system. |
| 163 |
returned: when present |
| 164 |
type: bool |
| 165 |
dnsServers: |
| 166 |
description: A list of DNS servers that are presented to the container. |
| 167 |
returned: when present |
| 168 |
type: str |
| 169 |
dnsSearchDomains: |
| 170 |
description: A list of DNS search domains that are presented to the container. |
| 171 |
returned: when present |
| 172 |
type: str |
| 173 |
extraHosts: |
| 174 |
description: A list of hostnames and IP address mappings to append to the /etc/hosts file on the container. |
| 175 |
returned: when present |
| 176 |
type: complex |
| 177 |
contains: |
| 178 |
hostname: |
| 179 |
description: The hostname to use in the /etc/hosts entry. |
| 180 |
returned: when present |
| 181 |
type: str |
| 182 |
ipAddress: |
| 183 |
description: The IP address to use in the /etc/hosts entry. |
| 184 |
returned: when present |
| 185 |
type: str |
| 186 |
dockerSecurityOptions: |
| 187 |
description: A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems. |
| 188 |
returned: when present |
| 189 |
type: str |
| 190 |
dockerLabels: |
| 191 |
description: A key/value map of labels to add to the container. |
| 192 |
returned: when present |
| 193 |
type: str |
| 194 |
ulimits: |
| 195 |
description: A list of ulimits to set in the container. |
| 196 |
returned: when present |
| 197 |
type: complex |
| 198 |
contains: |
| 199 |
name: |
| 200 |
description: The type of the ulimit . |
| 201 |
returned: when present |
| 202 |
type: str |
| 203 |
softLimit: |
| 204 |
description: The soft limit for the ulimit type. |
| 205 |
returned: when present |
| 206 |
type: int |
| 207 |
hardLimit: |
| 208 |
description: The hard limit for the ulimit type. |
| 209 |
returned: when present |
| 210 |
type: int |
| 211 |
logConfiguration: |
| 212 |
description: The log configuration specification for the container. |
| 213 |
returned: when present |
| 214 |
type: str |
| 215 |
options: |
| 216 |
description: The configuration options to send to the log driver. |
| 217 |
returned: when present |
| 218 |
type: str |
| 219 |
healthCheck: |
| 220 |
description: The container health check command and associated configuration parameters for the container. |
| 221 |
returned: when present |
| 222 |
type: dict |
| 223 |
contains: |
| 224 |
command: |
| 225 |
description: A string array representing the command that the container runs to determine if it is healthy. |
| 226 |
type: list |
| 227 |
interval: |
| 228 |
description: The time period in seconds between each health check execution. |
| 229 |
type: int |
| 230 |
timeout: |
| 231 |
description: The time period in seconds to wait for a health check to succeed before it is considered a failure. |
| 232 |
type: int |
| 233 |
retries: |
| 234 |
description: The number of times to retry a failed health check before the container is considered unhealthy. |
| 235 |
type: int |
| 236 |
startPeriod: |
| 237 |
description: The optional grace period to provide containers time to bootstrap before failed. |
| 238 |
type: int |
| 239 |
resourceRequirements: |
| 240 |
description: The type and amount of a resource to assign to a container. |
| 241 |
returned: when present |
| 242 |
type: dict |
| 243 |
contains: |
| 244 |
value: |
| 245 |
description: The value for the specified resource type. |
| 246 |
type: str |
| 247 |
type: |
| 248 |
description: The type of resource to assign to a container. |
| 249 |
type: str |
| 250 |
systemControls: |
| 251 |
description: A list of namespaced kernel parameters to set in the container. |
| 252 |
returned: when present |
| 253 |
type: dict |
| 254 |
contains: |
| 255 |
namespace: |
| 256 |
description: TThe namespaced kernel. |
| 257 |
type: str |
| 258 |
value: |
| 259 |
description: The value for the namespaced kernel. |
| 260 |
type: str |
| 261 |
firelensConfiguration: |
| 262 |
description: The FireLens configuration for the container. |
| 263 |
returned: when present |
| 264 |
type: dict |
| 265 |
contains: |
| 266 |
type: |
| 267 |
description: The log router. |
| 268 |
type: str |
| 269 |
options: |
| 270 |
description: The options to use when configuring the log router. |
| 271 |
type: dict |
| 272 |
family: |
| 273 |
description: The family of your task definition, used as the definition name |
| 274 |
returned: always |
| 275 |
type: str |
| 276 |
task_definition_arn: |
| 277 |
description: ARN of the task definition |
| 278 |
returned: always |
| 279 |
type: str |
| 280 |
task_role_arn: |
| 281 |
description: The ARN of the IAM role that containers in this task can assume |
| 282 |
returned: when role is set |
| 283 |
type: str |
| 284 |
network_mode: |
| 285 |
description: Network mode for the containers |
| 286 |
returned: always |
| 287 |
type: str |
| 288 |
revision: |
| 289 |
description: Revision number that was queried |
| 290 |
returned: always |
| 291 |
type: int |
| 292 |
volumes: |
| 293 |
description: The list of volumes in a task |
| 294 |
returned: always |
| 295 |
type: complex |
| 296 |
contains: |
| 297 |
name: |
| 298 |
description: The name of the volume. |
| 299 |
returned: when present |
| 300 |
type: str |
| 301 |
host: |
| 302 |
description: The contents of the host parameter determine whether your data volume |
| 303 |
persists on the host container instance and where it is stored. |
| 304 |
returned: when present |
| 305 |
type: bool |
| 306 |
source_path: |
| 307 |
description: The path on the host container instance that is presented to the container. |
| 308 |
returned: when present |
| 309 |
type: str |
| 310 |
status: |
| 311 |
description: The status of the task definition |
| 312 |
returned: always |
| 313 |
type: str |
| 314 |
requires_attributes: |
| 315 |
description: The container instance attributes required by your task |
| 316 |
returned: when present |
| 317 |
type: complex |
| 318 |
contains: |
| 319 |
name: |
| 320 |
description: The name of the attribute. |
| 321 |
returned: when present |
| 322 |
type: str |
| 323 |
value: |
| 324 |
description: The value of the attribute. |
| 325 |
returned: when present |
| 326 |
type: str |
| 327 |
targetType: |
| 328 |
description: The type of the target with which to attach the attribute. |
| 329 |
returned: when present |
| 330 |
type: str |
| 331 |
targetId: |
| 332 |
description: The ID of the target. |
| 333 |
returned: when present |
| 334 |
type: str |
| 335 |
placement_constraints: |
| 336 |
description: A list of placement constraint objects to use for tasks |
| 337 |
returned: always |
| 338 |
type: complex |
| 339 |
contains: |
| 340 |
type: |
| 341 |
description: The type of constraint. |
| 342 |
returned: when present |
| 343 |
type: str |
| 344 |
expression: |
| 345 |
description: A cluster query language expression to apply to the constraint. |
| 346 |
returned: when present |
| 347 |
type: str |
| 348 |
""" |
| 349 |
|
| 350 |
try: |
| 351 |
import botocore |
| 352 |
except ImportError: |
| 353 |
pass # caught by AnsibleAWSModule |
| 354 |
|
| 355 |
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict |
| 356 |
|
| 357 |
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule |
| 358 |
|
| 359 |
|
| 360 |
def main(): |
| 361 |
argument_spec = dict( |
| 362 |
task_definition=dict(required=True, type="str"), |
| 363 |
) |
| 364 |
|
| 365 |
module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) |
| 366 |
|
| 367 |
ecs = module.client("ecs") |
| 368 |
|
| 369 |
try: |
| 370 |
ecs_td = ecs.describe_task_definition(taskDefinition=module.params["task_definition"])["taskDefinition"] |
| 371 |
except botocore.exceptions.ClientError: |
| 372 |
ecs_td = {} |
| 373 |
|
| 374 |
module.exit_json(changed=False, **camel_dict_to_snake_dict(ecs_td)) |
| 375 |
|
| 376 |
|
| 377 |
if __name__ == "__main__": |
| 378 |
main() |