)]}'
{"functions.sh":[{"author":{"_account_id":2,"name":"Monty Taylor","email":"mordred@inaugust.com","username":"mordred"},"change_message_id":"e76d93da4fb6a2dee3c261c11d3cb43dc09e4da7","unresolved":false,"context_lines":[{"line_number":589,"context_line":""},{"line_number":590,"context_line":"function setup_host {"},{"line_number":591,"context_line":"    # This is necessary to keep sudo from complaining"},{"line_number":592,"context_line":"    fix_etc_hosts"},{"line_number":593,"context_line":""},{"line_number":594,"context_line":"    # We set some home directories under $BASE, make sure it exists."},{"line_number":595,"context_line":"    sudo mkdir -p $BASE"}],"source_content_type":"text/x-sh","patch_set":3,"id":"5a74a57a_9c62b23c","side":"PARENT","line":592,"updated":"2016-11-29 15:00:19.000000000","message":"Maybe delete the fix_etc_hosts function as well (makes it easier to review)","commit_id":"1fdeb6e027b9c5aec5a4d10dcdecab43d9a1667a"}],"playbooks/roles/fix_etc_hosts/tasks/main.yaml":[{"author":{"_account_id":4146,"name":"Clark Boylan","email":"cboylan@sapwetik.org","username":"cboylan"},"change_message_id":"643d550a61834ffe84ea643762b6da84e7274e91","unresolved":false,"context_lines":[{"line_number":1,"context_line":"---"},{"line_number":2,"context_line":"- name: Add hostname to /etc/hosts"},{"line_number":3,"context_line":"  lineinfile: dest\u003d/etc/hosts regexp\u003d{{ ansible_hostname }} line\u003d\u0027127.0.1.1 {{ ansible_hostname }}\u0027"},{"line_number":4,"context_line":"  become: yes"}],"source_content_type":"text/x-yaml","patch_set":7,"id":"5a74a57a_465abb84","line":3,"updated":"2016-11-30 20:08:56.000000000","message":"This doesn\u0027t do what the old code did. What we want is to add the line for hostname if the hostname is not in the file at all, otherwise leave the file alone.\n\nWhat this does is it will replace the last line with hostname in it with the specified line.","commit_id":"a159953a6c2248dd0a0ad249abfaf6367a7ab9ce"},{"author":{"_account_id":6589,"name":"Jesse Keating","email":"jkeating@j2solutions.net","username":"jesse-keating"},"change_message_id":"345e3604c38a64f778c336a0548bd1b806771020","unresolved":false,"context_lines":[{"line_number":4,"context_line":"  changed_when: False"},{"line_number":5,"context_line":"  failed_when: False"},{"line_number":6,"context_line":"  register: grep_out"},{"line_number":7,"context_line":"- name: Add hostname to /etc/hosts"},{"line_number":8,"context_line":"  lineinfile: dest\u003d/etc/hosts insertafter\u003dEOF line\u003d\u0027127.0.1.1 {{ ansible_hostname }}\u0027"},{"line_number":9,"context_line":"  become: yes"},{"line_number":10,"context_line":"  when: grep_out.rc !\u003d 0"}],"source_content_type":"text/x-yaml","patch_set":12,"id":"1a6eadb0_b91da5bf","line":7,"updated":"2016-12-12 23:19:46.000000000","message":"In general, things are easier to read when there is a new line between tasks.","commit_id":"98725280555c7f1d539cedc3a2a516369e0a215c"},{"author":{"_account_id":1106,"name":"Ricardo Carrillo Cruz","email":"ricardo.carrillo.cruz@gmail.com","username":"rcc"},"change_message_id":"5b9e7d6589452dcbb8aa5588aa06ea3271968a9c","unresolved":false,"context_lines":[{"line_number":4,"context_line":"  changed_when: False"},{"line_number":5,"context_line":"  failed_when: False"},{"line_number":6,"context_line":"  register: grep_out"},{"line_number":7,"context_line":"- name: Add hostname to /etc/hosts"},{"line_number":8,"context_line":"  lineinfile: dest\u003d/etc/hosts insertafter\u003dEOF line\u003d\u0027127.0.1.1 {{ ansible_hostname }}\u0027"},{"line_number":9,"context_line":"  become: yes"},{"line_number":10,"context_line":"  when: grep_out.rc !\u003d 0"}],"source_content_type":"text/x-yaml","patch_set":12,"id":"1a6eadb0_6f8328cd","line":7,"in_reply_to":"1a6eadb0_b91da5bf","updated":"2016-12-13 11:30:57.000000000","message":"Done","commit_id":"98725280555c7f1d539cedc3a2a516369e0a215c"},{"author":{"_account_id":6589,"name":"Jesse Keating","email":"jkeating@j2solutions.net","username":"jesse-keating"},"change_message_id":"345e3604c38a64f778c336a0548bd1b806771020","unresolved":false,"context_lines":[{"line_number":7,"context_line":"- name: Add hostname to /etc/hosts"},{"line_number":8,"context_line":"  lineinfile: dest\u003d/etc/hosts insertafter\u003dEOF line\u003d\u0027127.0.1.1 {{ ansible_hostname }}\u0027"},{"line_number":9,"context_line":"  become: yes"},{"line_number":10,"context_line":"  when: grep_out.rc !\u003d 0"}],"source_content_type":"text/x-yaml","patch_set":12,"id":"1a6eadb0_79222dbb","line":10,"updated":"2016-12-12 23:19:46.000000000","message":"What if instead of two tasks, you used one task and used a regex to search for the hostname in the file?\n\n- name: Ensure hostname in /etc/hosts\n  lineinfile:\n    regexp: \"{{ ansible_hostname | replace(\u0027.\u0027, \u0027\\.\u0027) }}\"\n    line: \"127.0.1.1 {{ ansible_hostname }}\"\n    insertafter: EOF\n    become: yes\n\nMight this work?","commit_id":"98725280555c7f1d539cedc3a2a516369e0a215c"},{"author":{"_account_id":6589,"name":"Jesse Keating","email":"jkeating@j2solutions.net","username":"jesse-keating"},"change_message_id":"5293e9dc0fcb3f30a3191cfe6570142b27bb9040","unresolved":false,"context_lines":[{"line_number":7,"context_line":"- name: Add hostname to /etc/hosts"},{"line_number":8,"context_line":"  lineinfile: dest\u003d/etc/hosts insertafter\u003dEOF line\u003d\u0027127.0.1.1 {{ ansible_hostname }}\u0027"},{"line_number":9,"context_line":"  become: yes"},{"line_number":10,"context_line":"  when: grep_out.rc !\u003d 0"}],"source_content_type":"text/x-yaml","patch_set":12,"id":"1a6eadb0_f49f24b2","line":10,"in_reply_to":"1a6eadb0_79222dbb","updated":"2016-12-12 23:26:03.000000000","message":"Found a better filter to make a regex string:\n\n  regexp: \"{{ ansible_hostname | regex_escape() }}\"","commit_id":"98725280555c7f1d539cedc3a2a516369e0a215c"},{"author":{"_account_id":6589,"name":"Jesse Keating","email":"jkeating@j2solutions.net","username":"jesse-keating"},"change_message_id":"7c4db131c8886538b76fe42d4845e9fdc1a0dcf6","unresolved":false,"context_lines":[{"line_number":8,"context_line":"- name: Add hostname to /etc/hosts"},{"line_number":9,"context_line":"  lineinfile: dest\u003d/etc/hosts insertafter\u003dEOF line\u003d\u0027127.0.1.1 {{ ansible_hostname }}\u0027"},{"line_number":10,"context_line":"  become: yes"},{"line_number":11,"context_line":"  when: grep_out.rc !\u003d 0"}],"source_content_type":"text/x-yaml","patch_set":13,"id":"1a6eadb0_a14f02bc","line":11,"updated":"2016-12-13 18:11:44.000000000","message":"Now that I finally understand what the intent is here, there is a more Ansible way to do this rather than grepping and saving output.\n\n- name: Read /etc/hosts content\n  slurp:\n    src: /etc/hosts\n  register: hosts\n\n- name: Add hostname to /etc/hosts\n  lineinfile:\n    dest: /etc/hosts\n    insertafter: EOF\n    line: \"127.0.0.1 {{ ansible_hostname }}\"\n  become: yes\n  when: hosts | base64decode | search(ansible_hostname | regex_escape())\n\nBuuut the grepping is probably fine.","commit_id":"33a326691466ad41693598b9e9705778ee0c1032"},{"author":{"_account_id":4146,"name":"Clark Boylan","email":"cboylan@sapwetik.org","username":"cboylan"},"change_message_id":"2254abda4ee0e00fe5b47431e09f701f1d7feeff","unresolved":false,"context_lines":[{"line_number":8,"context_line":"- name: Add hostname to /etc/hosts"},{"line_number":9,"context_line":"  lineinfile: dest\u003d/etc/hosts insertafter\u003dEOF line\u003d\u0027127.0.1.1 {{ ansible_hostname }}\u0027"},{"line_number":10,"context_line":"  become: yes"},{"line_number":11,"context_line":"  when: grep_out.rc !\u003d 0"}],"source_content_type":"text/x-yaml","patch_set":13,"id":"1a6eadb0_aa59975c","line":11,"in_reply_to":"1a6eadb0_a14f02bc","updated":"2016-12-13 19:16:52.000000000","message":"FWIW if you need to understand what the code is trying to do I strongly recommend you refer back to the code that is being replaced by these playbooks. This is the behavior we are trying to preserve as we convert to playbooks.","commit_id":"33a326691466ad41693598b9e9705778ee0c1032"}]}
