Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VARIABLE IS NOT DEFINED from referenced variable with value #19135

Closed
bamb00 opened this issue Dec 10, 2016 · 5 comments
Closed

VARIABLE IS NOT DEFINED from referenced variable with value #19135

bamb00 opened this issue Dec 10, 2016 · 5 comments

Comments

@bamb00
Copy link

bamb00 commented Dec 10, 2016

ISSUE TYPE: Bug Report

COMPONENT NAME: Referencing from ecs_taskdefinition module

ANSIBLE VERSION: 2.1.1.0

CONFIGURATION: Nothing special

OS / ENVIRONMENT: Nothing special

SUMMARY: task_output result from a debug statement,

"task_output": {
     "changed": false, 
     "taskdefinition": {
         "containerDefinitions": [
             {
                 "cpu": 512, 
                 "environment": [], 
                 "essential": true, 
                 "image": "xxxxxxxxxxxxx.dkr.ecr.xx-xxxx-x.amazonaws.com/xxxx_xxx_framework:v0.1.4.58.xxxxxxxxx", 
                 "logConfiguration": {
                     "logDriver": "awslogs", 
                     "options": {
                         "awslogs-group": "ContainerLogsGroup", 
                         "awslogs-region": "xx-xxxx-x", 
                         "awslogs-stream-prefix": "xxxxt-xxxframework"
                     }
                 }, 
                 "memory": 1200, 
                 "mountPoints": [], 
                 "name": "xxxx-webframework", 
                 "portMappings": [
                     {
                         "containerPort": 3000, 
                         "hostPort": 3000, 
                         "protocol": "tcp"
                     }
                 ], 
                 "volumesFrom": []
             }
         ], 
         "family": "xxxx-webframework", 

STEPS TO REPRODUCE:
"- debug: var=task_output.taskdefinition.containerDefinitions[0].logConfiguration.options.awslogs-group"

EXPECTED RESULTS:
ContainerLogsGroup

ACTUAL RESULTS:
task_output.taskdefinition.containerDefinitions[0].logConfiguration.options.awslogs-group: "VARIABLE IS NOT DEFINED!"

NOTE:
The reference seems to be ok up to 'options',
ok: [localhost] => {
"task_output.taskdefinition.containerDefinitions[0].logConfiguration.options": {
"awslogs-group": "ContainerLogsGroup",
"awslogs-region": "xx-xxxx-x",
"awslogs-stream-prefix": "xxxx-webframework"
}
}

@bamb00 bamb00 changed the title VARIABLE IS NOT DEFINED from deep level of referencing VARIABLE IS NOT DEFINED from referenced variable with value Dec 10, 2016
@kkarimi
Copy link
Contributor

kkarimi commented Dec 10, 2016

This is not a bug, it happens because "awslogs-group" variable has a dash in the name which ansible will not handle (see e.g. #3907)

If you do have jq installed, you can use it to get the value with a task like this:

- shell: "aws ecs describe-task-definition --task-definition your_task_definition:task_revision | jq '.taskDefinition.containerDefinitions[0].logConfiguration.options.\"awslogs-group\"'"

@bamb00
Copy link
Author

bamb00 commented Dec 11, 2016

Hi, what is jq?

@kkarimi
Copy link
Contributor

kkarimi commented Dec 11, 2016

@bamb00 I updated it with a link, it's a JSON processor that will help to process the output from the task

@bamb00
Copy link
Author

bamb00 commented Dec 12, 2016

I wonder if I can use awk or sed to retrieve the awslogs-group instead of jq.

@kkarimi
Copy link
Contributor

kkarimi commented Dec 12, 2016

@bamb00 you can use whatever tool you like

@bamb00 bamb00 closed this as completed Dec 12, 2016
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants