Merge pull request #47 from generoi/issue-46

Fix passwordless sudo for vagrant when GNU sed is installed
This commit is contained in:
Jeff Geerling 2017-06-01 15:59:58 -05:00 committed by GitHub
commit 4ec9ad7c13
2 changed files with 16 additions and 5 deletions

View file

@ -1,10 +1,21 @@
--- ---
# If the user installs GNU sed through homebrew the path is different.
- name: Register path to sed.
command: which sed
register: sed_which_result
changed_when: false
when: sed_path is undefined
- name: Define sed_path variable.
set_fact:
sed_path: "{{ sed_which_result.stdout }}"
when: sed_path is undefined
# Sudoers configuration (enables more convenient Vagrant usage). # Sudoers configuration (enables more convenient Vagrant usage).
- name: Copy sudoers configuration into place. - name: Copy sudoers configuration into place.
copy: template:
src: files/etc/sudoers src: templates/sudoers.j2
dest: /etc/sudoers dest: /etc/sudoers
mode: 0440 mode: 0440
validate: 'visudo -cf %s' validate: 'visudo -cf %s'
become: yes become: yes
when: configure_sudoers

View file

@ -47,7 +47,7 @@ root ALL=(ALL) ALL
# Vagrant sudoers config # Vagrant sudoers config
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports Cmnd_Alias VAGRANT_EXPORTS_REMOVE = {{ sed_path }} -E -e /*/ d -ibak /etc/exports
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /usr/bin/sed -i -e /*/ d /etc/hosts Cmnd_Alias VAGRANT_HOSTS_REMOVE = {{ sed_path }} -i -e /*/ d /etc/hosts
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE, VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE %admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE, VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE