{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/18111","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/18111/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/18111/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/18111/events","html_url":"https://github.com/ansible/ansible/issues/18111","id":184067088,"number":18111,"title":"The value of 'serial' in playbook cannot be set based on a variable defined per group","user":{"login":"FlorinAndrei","id":901867,"avatar_url":"https://avatars.githubusercontent.com/u/901867?v=3","gravatar_id":"","url":"https://api.github.com/users/FlorinAndrei","html_url":"https://github.com/FlorinAndrei","followers_url":"https://api.github.com/users/FlorinAndrei/followers","following_url":"https://api.github.com/users/FlorinAndrei/following{/other_user}","gists_url":"https://api.github.com/users/FlorinAndrei/gists{/gist_id}","starred_url":"https://api.github.com/users/FlorinAndrei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FlorinAndrei/subscriptions","organizations_url":"https://api.github.com/users/FlorinAndrei/orgs","repos_url":"https://api.github.com/users/FlorinAndrei/repos","events_url":"https://api.github.com/users/FlorinAndrei/events{/privacy}","received_events_url":"https://api.github.com/users/FlorinAndrei/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-19T20:35:13Z","updated_at":"2016-10-20T18:14:27Z","closed_at":"2016-10-20T02:51:06Z","body":"##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest: -->\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\n<!--- Name of the plugin/task/feature -->\r\nplaybook\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\r\n```\r\nansible 1.9.4\r\n  configured module search path = None\r\n```\r\n\r\n##### CONFIGURATION\r\n<!---\r\nMention any settings you have changed/added/removed in ansible.cfg\r\n(or using the ANSIBLE_* environment variables).\r\n-->\r\n\r\n##### OS / ENVIRONMENT\r\n<!---\r\nMention the OS you are running Ansible from, and the OS you are\r\nmanaging, or say “N/A” for anything that is not platform-specific.\r\n-->\r\nN/A\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly -->\r\nDoing rolling updates with Ansible.\r\n\r\n```\r\nansible-playbook -i production deploy.yml\r\n\r\nansible-playbook -i staging deploy.yml\r\n```\r\n\r\n```\r\n$ cat deploy.yml\r\n---\r\n- hosts: api_frontend\r\n  serial: 4\r\n\r\n  pre_tasks:\r\n    - name: \"Gather EC2 facts from API nodes\"\r\n      ec2_facts:\r\n\r\n    - name: \"Remove node from ELB\"\r\n      local_action: ec2_elb\r\n      args:\r\n        instance_id: \"{{ ansible_ec2_instance_id }}\"\r\n        region: \"{{ aws.region }}\"\r\n        ec2_elbs: \"{{ aws_api_lb }}\"\r\n        state: \"absent\"\r\n\r\n  roles:\r\n    - { role: api-deploy }\r\n\r\n  post_tasks:\r\n    - name: \"Add node to ELB\"\r\n      local_action: ec2_elb\r\n      args:\r\n        instance_id: \"{{ ansible_ec2_instance_id }}\"\r\n        region: \"{{ aws.region }}\"\r\n        ec2_elbs: \"{{ aws_api_lb }}\"\r\n        state: \"present\"\r\n        wait_timeout: 30\r\n```\r\n\r\nThe problem is, `serial: 4` works well in production, but the value is too large for staging. In staging I'd like to use `serial: 1`.\r\n\r\nI've tried to define a variable such as `api_deploy_serial` in places like `production/group_vars/all/vars` (and also for staging), and used that to define the value for serial in the playbook, but it does not seem to be taken into account. Seems like variables are evaluated after serial is used in the playbook.\r\n\r\nI do not want to maintain multiple deploy playbooks, one for each environment. That playbook needs to be created once, and pull variables from various environments for various behaviors. That's how config management is supposed to work.\r\n\r\nHaving multiple playbooks, one per environment, without the ability to template the behavior in the standard way, would be like a throw back to the bad old days of shell scripts.\r\n\r\n##### STEPS TO REPRODUCE\r\n<!---\r\nFor bugs, show exactly how to reproduce the problem.\r\nFor new features, show how the feature would be used.\r\n-->\r\n\r\nIf I do:\r\n\r\n```\r\nserial: \"{{ api_deploy_serial | default(1) | int }}\"\r\n```\r\n\r\nthen only the default value is used, no matter what I add to `group_vars`.\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```\r\n\r\n```\r\n\r\n<!--- You can also paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n<!--- What did you expect to happen when running the steps above? -->\r\n\r\n##### ACTUAL RESULTS\r\n<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->\r\n\r\n<!--- Paste verbatim command output between quotes below -->\r\n```\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/255184930","html_url":"https://github.com/ansible/ansible/issues/18111#issuecomment-255184930","issue_url":"https://api.github.com/repos/ansible/ansible/issues/18111","id":255184930,"user":{"login":"FlorinAndrei","id":901867,"avatar_url":"https://avatars.githubusercontent.com/u/901867?v=3","gravatar_id":"","url":"https://api.github.com/users/FlorinAndrei","html_url":"https://github.com/FlorinAndrei","followers_url":"https://api.github.com/users/FlorinAndrei/followers","following_url":"https://api.github.com/users/FlorinAndrei/following{/other_user}","gists_url":"https://api.github.com/users/FlorinAndrei/gists{/gist_id}","starred_url":"https://api.github.com/users/FlorinAndrei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FlorinAndrei/subscriptions","organizations_url":"https://api.github.com/users/FlorinAndrei/orgs","repos_url":"https://api.github.com/users/FlorinAndrei/repos","events_url":"https://api.github.com/users/FlorinAndrei/events{/privacy}","received_events_url":"https://api.github.com/users/FlorinAndrei/received_events","type":"User","site_admin":false},"created_at":"2016-10-20T18:14:26Z","updated_at":"2016-10-20T18:14:26Z","body":"@bcoca That was disappointing.\r\n\r\nThere's no misunderstanding here. The actual behavior you're describing is what I say is wrong, and limits the flexibility of this software. I am not speaking from a theoretical ivory tower here, but from a practical perspective - *in practice* you want your serial value to change based on where the playbook is being run. In some environments you want higher values for serial, in other environments you want lower values.\r\n\r\nPlease step out for a moment from the perspective of the coder, and look at Ansible from the perspective of the user. What we have here is a parameter that is hardcoded in a file, impossible to control via the usual strategies used for all other parameters. It's jarring because, again, *from the perspective of the user* Ansible exhibits an inconsistency in its behavior."}}
{"actor":{"display_login":"FlorinAndrei"}}