You can use user_data to fix the /etc/sudoers file

like (may need adjustment)

sed -i -e 's/Defaults\\s*requiretty$/#Defaults\trequiretty/' /etc/sudoers
sed -i -e '/# %wheel\tALL=(ALL)\tNOPASSWD: ALL/a %vagrant\tALL=(ALL)\tNOPASSWD:
ALL' /etc/sudoers Alvaro.

On Tue, Nov 7, 2017 at 7:03 AM, Rajinder Singh <[email protected]> wrote:

> I am baking a Ubuntu 16.04 VM in Azure.
>
> I tried this
>
>  {
>
>       "type": "ansible",
>
>       "ansible_env_vars": [ "ANSIBLE_HOST_KEY_CHECKING=False",
> "ANSIBLE_SSH_ARGS='-o ForwardAgent=yes -o ControlMaster=auto -o
> ControlPersist=60s'", "ANSIBLE_NOCOLOR=True" ],
>
>       "playbook_file": "./hardening_playbook.yml"
>
>  }
>
>
> and
>
>
>  {
>
>       "type": "ansible",
>
>       "playbook_file": "./hardening_playbook.yml"
>
>  }
>
>
>
> ansible playbook has this:
>
>
> #5.1.4.7 Set appropriate timeout for sudo.
>
>     - name: sudo timeout
>
>       lineinfile: dest=/etc/sudoers
>
>                    regexp="^Defaults    env_reset"
>
>                    line="Defaults    env_reset,timestamp_timeout=2"
>
>                    state=present
>
>
>
> It is failing with this error below
>
> TASK [sudo timeout] ******************************
> ******************************
>
>     azure-arm: fatal: [default]: FAILED! => {"changed": false, "failed":
> true, "module_stderr": "sudo: a password is required\nShared connection to
> 127.0.0.1 closed.\r\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc":
> 1}
>
>     azure-arm: to retry
>
>
>
>
>
> Let me know if you have any suggestions.
>
>
>
> Thanks
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/packer-tool/4cdd3a34-1927-4ba2-926c-b3dea9afe475%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/4cdd3a34-1927-4ba2-926c-b3dea9afe475%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Alvaro

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CAHqq0ewkUvM%2B_htdr2b%3Dy0h1o%3DJWD5F40h-HRvkw_o82Lc%2BXhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to