{"id":81,"date":"2018-10-21T15:34:39","date_gmt":"2018-10-21T13:34:39","guid":{"rendered":"http:\/\/deleforterie.com\/wordpress\/?p=81"},"modified":"2023-01-18T08:53:12","modified_gmt":"2023-01-18T07:53:12","slug":"ansible-become_user-and-include_tasks-modification-since-2-5","status":"publish","type":"post","link":"https:\/\/deleforterie.com\/wordpress\/index.php\/2018\/10\/21\/ansible-become_user-and-include_tasks-modification-since-2-5\/","title":{"rendered":"Ansible &#8211; become_user and include_tasks modification since 2.5"},"content":{"rendered":"<p>There is a modification since Ansible 2.5 with the way that include_tasks works with become_user<\/p>\n<p><!--more--><\/p>\n<p>Before Ansible 2.5, your code like this one works fine, you will have the Sylvie user id<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\">---\n- hosts: localhost\n  gather_facts: no\n  tasks:\n    - name: test\n      include_tasks: test_include_id.yml\n      become: yes\n      become_user: sylvie<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\">---\n- shell: id\n<\/pre>\n<p>Since Ansible 2.5 a change in&nbsp;<a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/porting_guides\/porting_guide_2.5.html#dynamic-includes-and-attribute-inheritance\">Dynamic includes and attribute inheritance<\/a> was implemented causing this previous playbook to show your user id instead of Sylvie user id.<\/p>\n<p>Since Ansible 2.5 use this syntax with a <strong>block<\/strong> to have the <strong>become_user<\/strong> works<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\">---\n- hosts: localhost\n  gather_facts: no\n  tasks:\n    - block:\n      - name: test\n        include_tasks: test_include_id.yml\n      become: yes\n      become_user: sylvie<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a modification since Ansible 2.5 with the way that include_tasks works with become_user<\/p>\n","protected":false},"author":2,"featured_media":155,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-81","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ansible"],"_links":{"self":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=81"}],"version-history":[{"count":6,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":154,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/81\/revisions\/154"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/media\/155"}],"wp:attachment":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}