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

every run of elasticbeanstalk_env redeploys the environment, even when no changes #24

Open
nergdron opened this issue Jan 18, 2017 · 17 comments

Comments

@nergdron
Copy link

It'd be great if there was a way for it to diff new settings vs what's currently there in an environment, and not redeploy if there haven't been any changes. This is typically how ansible modules behave, and would save my particular workflow a lot of runtime.

@hsingh
Copy link
Owner

hsingh commented Jan 18, 2017 via email

@nergdron
Copy link
Author

Right. But if I'm in a playbook that loops through and creates/updates say, 10 EB environments... I don't want it to redeploy ones that haven't changed, as it adds an extra ~10m to the run for each one. --check on the whole playbook won't help me there, AFAIK.

@sidewinder12s
Copy link
Contributor

I think I had noticed this as well, I wasn't sure if this was the same with the boto version. Normally with Ansible modules if all settings are the same (and app version in this case as well), ansible shouldn't perform any changes.

@nergdron
Copy link
Author

I think boto does the same thing, tbh. This is definitely a feature request, but I'd love to see the ansible module act smarter than boto does, and save me some time during deploys. :)

@hsingh
Copy link
Owner

hsingh commented Jan 18, 2017 via email

@hsingh
Copy link
Owner

hsingh commented Jan 18, 2017

Please provide an example to reproduce this scenario.

@sidewinder12s
Copy link
Contributor

I created a playbook that just called create twice with the same option settings & application version, with a 30 second wait between them & Ansible outputted the changed: true twice instead of changing the first run and then unchanged the second. The EB console showed an environment configuration update & an application version update

@hsingh
Copy link
Owner

hsingh commented Jan 24, 2017

If you look at the code update_environment is only called if we detect a change.

updates = update_required(ebs, env, module.params)
            if len(updates) > 0:
                ebs.update_environment(**filter_empty(...

So in your test case what updates were reported when by the second run?

@sidewinder12s
Copy link
Contributor

Interesting, looks like it was some of the option settings I was using that was causing it to update configuration settings ever time, this time specifically the aws:autoscaling:scheduledaction namespace.

TASK [Create environment] ******************************************************
changed: [localhost] => {"changed": true, "env": {"AbortableOperationInProgress": false, "ApplicationName": "elasticbeanstalk_env-testing", "CNAME": "elasticbeanstalk-env-testing.us-west-2.elasticbeanstalk.com", "DateCreated": "2017-01-20T20:02:03.131000+00:00", "DateUpdated": "2017-01-24T20:15:25.559000+00:00", "EndpointURL": "internal-awseb-e-7-AWSEBLoa-1H7KXPZ49YTRI-864563399.us-west-2.elb.amazonaws.com", "EnvironmentId": "e-7kgfsghi3w", "EnvironmentLinks": [], "EnvironmentName": "elasticbeanstalk-env-testing", "Health": "Green", "SolutionStackName": "64bit Amazon Linux 2016.09 v2.3.1 running Tomcat 8 Java 8", "Status": "Ready", "Tier": {"Name": "WebServer", "Type": "Standard", "Version": "1.0"}, "VersionLabel": "Testing"}, "updates": [["aws:autoscaling:scheduledaction:MinSize", "0", "1"], ["aws:autoscaling:scheduledaction:MaxSize", "0", "2"], ["aws:autoscaling:scheduledaction:Recurrence", "0 3 * * 1-5", "0 17 * * 1-5"]]}

TASK [debug] *******************************************************************
ok: [localhost] => {
    "deploy_status": {
        "changed": true,
        "env": {
            "AbortableOperationInProgress": false,
            "ApplicationName": "elasticbeanstalk_env-testing",
            "CNAME": "elasticbeanstalk-env-testing.us-west-2.elasticbeanstalk.com",
            "DateCreated": "2017-01-20T20:02:03.131000+00:00",
            "DateUpdated": "2017-01-24T20:15:25.559000+00:00",
            "EndpointURL": "internal-awseb-e-7-AWSEBLoa-1H7KXPZ49YTRI-864563399.us-west-2.elb.amazonaws.com",
            "EnvironmentId": "e-7kgfsghi3w",
            "EnvironmentLinks": [],
            "EnvironmentName": "elasticbeanstalk-env-testing",
            "Health": "Green",
            "SolutionStackName": "64bit Amazon Linux 2016.09 v2.3.1 running Tomcat 8 Java 8",
            "Status": "Ready",
            "Tier": {
                "Name": "WebServer",
                "Type": "Standard",
                "Version": "1.0"
            },
            "VersionLabel": "Testing"
        },
        "updates": [
            [
                "aws:autoscaling:scheduledaction:MinSize",
                "0",
                "1"
            ],
            [
                "aws:autoscaling:scheduledaction:MaxSize",
                "0",
                "2"
            ],
            [
                "aws:autoscaling:scheduledaction:Recurrence",
                "0 3 * * 1-5",
                "0 17 * * 1-5"
            ]
        ]
    }
}

TASK [Wait to ensure the API doesn't return stale objects] *********************
Pausing for 30 seconds
(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)
ok: [localhost] => {"changed": false, "delta": 30, "rc": 0, "start": "2017-01-24 20:15:25.657782", "stderr": "", "stdout": "Paused for 30.0 seconds", "stop": "2017-01-24 20:15:55.657926", "user_input": ""}

TASK [Create environment (idempotent)] *****************************************
changed: [localhost] => {"changed": true, "env": {"AbortableOperationInProgress": false, "ApplicationName": "elasticbeanstalk_env-testing", "CNAME": "elasticbeanstalk-env-testing.us-west-2.elasticbeanstalk.com", "DateCreated": "2017-01-20T20:02:03.131000+00:00", "DateUpdated": "2017-01-24T20:17:14.099000+00:00", "EndpointURL": "internal-awseb-e-7-AWSEBLoa-1H7KXPZ49YTRI-864563399.us-west-2.elb.amazonaws.com", "EnvironmentId": "e-7kgfsghi3w", "EnvironmentLinks": [], "EnvironmentName": "elasticbeanstalk-env-testing", "Health": "Green", "SolutionStackName": "64bit Amazon Linux 2016.09 v2.3.1 running Tomcat 8 Java 8", "Status": "Ready", "Tier": {"Name": "WebServer", "Type": "Standard", "Version": "1.0"}, "VersionLabel": "Testing"}, "updates": [["aws:autoscaling:scheduledaction:MinSize", "0", "1"], ["aws:autoscaling:scheduledaction:MaxSize", "0", "2"], ["aws:autoscaling:scheduledaction:Recurrence", "0 3 * * 1-5", "0 17 * * 1-5"]]}

This env hadn't changed between runs but was being updated both times. Any idea if that is on the module end that is causing it to set it every time or on the API end?

@hsingh
Copy link
Owner

hsingh commented Jan 24, 2017

Hmm, not sure. According to the module the 3 options (MinSize, MaxSize, Recurrence) changed from what is currently deployed. I haven't used these options before so can't say. There is some specific code in the module to deal with options that take comma separate listed of values like subnet and security groups where we deal with transposed values. This doesn't seem to be the case here so either your initial values were not accepted by AWS, changed between the two invocations or the second invocation used a different input.

@sidewinder12s
Copy link
Contributor

They used the same input as I am just setting a fact at the beginning of the run with all the option_settings, I was left wondering if the module isn't properly looking at the returned input

@sidewinder12s
Copy link
Contributor

@nergdron Do you know what the module is saying gets updated when your expecting it to have done nothing?

@nergdron
Copy link
Author

Yeah, I can repro that some time this week. Just been out with the flu, so I'm busy trying to catch up. :)

@nergdron
Copy link
Author

nergdron commented Feb 8, 2017

Sorry it took so long to test this, but here's the updates field of the result when it re-applies the config:

    "updates": [
        [
            "aws:elb:policies:ConnectionDrainingEnabled", 
            "true", 
            "True"
        ], 
        [
            "aws:elb:loadbalancer:CrossZone", 
            "true", 
            "True"
        ], 
        [
            "aws:autoscaling:updatepolicy:rollingupdate:autoscaling:trigger:RollingUpdateEnabled", 
            "<NEW>", 
            "True"
        ], 
        [
            "aws:autoscaling:updatepolicy:rollingupdate:autoscaling:trigger:RollingUpdateType", 
            "<NEW>", 
            "Health"
        ]
    ]

So, the first two seem to be problems with treating booleans as strings and case differences, and the last two don't seem to be correctly reading the current values from the running EB stack, since they were correctly applied the first time 'round.

@devarpi-zz
Copy link

How can I deploy new version. When I change the version_label I am getting following error
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/var/folders/ws/z_4zkk0s2vdfxvv7x6dmv_9r0000gp/T/ansible_vH17hS/ansible_module_elasticbeanstalk_env.py", line 410, in
main()
File "/var/folders/ws/z_4zkk0s2vdfxvv7x6dmv_9r0000gp/T/ansible_vH17hS/ansible_module_elasticbeanstalk_env.py", line 346, in main
check_env(ebs, app_name, env_name, module)
File "/var/folders/ws/z_4zkk0s2vdfxvv7x6dmv_9r0000gp/T/ansible_vH17hS/ansible_module_elasticbeanstalk_env.py", line 262, in check_env
updates = update_required(ebs, env, module.params)
File "/var/folders/ws/z_4zkk0s2vdfxvv7x6dmv_9r0000gp/T/ansible_vH17hS/ansible_module_elasticbeanstalk_env.py", line 232, in update_required
change = new_or_changed_option(options, setting)
File "/var/folders/ws/z_4zkk0s2vdfxvv7x6dmv_9r0000gp/T/ansible_vH17hS/ansible_module_elasticbeanstalk_env.py", line 246, in new_or_changed_option
option["Value"] == setting["Value"]:
KeyError: 'Value'

fatal: [localhost]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_name": "elasticbeanstalk_env"
},
"module_stderr": "Traceback (most recent call last):\n File "/var/folders/ws/z_4zkk0s2vdfxvv7x6dmv_9r0000gp/T/ansible_vH17hS/ansible_module_elasticbeanstalk_env.py", line 410, in \n main()\n File "/var/folders/ws/z_4zkk0s2vdfxvv7x6dmv_9r0000gp/T/ansible_vH17hS/ansible_module_elasticbeanstalk_env.py", line 346, in main\n check_env(ebs, app_name, env_name, module)\n File "/var/folders/ws/z_4zkk0s2vdfxvv7x6dmv_9r0000gp/T/ansible_vH17hS/ansible_module_elasticbeanstalk_env.py", line 262, in check_env\n updates = update_required(ebs, env, module.params)\n File "/var/folders/ws/z_4zkk0s2vdfxvv7x6dmv_9r0000gp/T/ansible_vH17hS/ansible_module_elasticbeanstalk_env.py", line 232, in update_required\n change = new_or_changed_option(options, setting)\n File "/var/folders/ws/z_4zkk0s2vdfxvv7x6dmv_9r0000gp/T/ansible_vH17hS/ansible_module_elasticbeanstalk_env.py", line 246, in new_or_changed_option\n option["Value"] == setting["Value"]:\nKeyError: 'Value'\n",
"module_stdout": "",
"msg": "MODULE FAILURE"
}

@sidewinder12s
Copy link
Contributor

@devarpi What does your playbook look like? It looks like it's complaining about the Option Settings your using/formatting of those option settings.

@devarpi-zz
Copy link

devarpi-zz commented Mar 28, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants