Skip to content

Commit

Permalink
Fixes geerlingguy#5: Add /etc/sudoers configuration for more Vagrant …
Browse files Browse the repository at this point in the history
…convenience.
  • Loading branch information
geerlingguy committed Jul 19, 2015
1 parent a71b353 commit cd63f37
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
53 changes: 53 additions & 0 deletions files/etc/sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification
Defaults env_reset
Defaults env_keep += "BLOCKSIZE"
Defaults env_keep += "COLORFGBG COLORTERM"
Defaults env_keep += "__CF_USER_TEXT_ENCODING"
Defaults env_keep += "CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE"
Defaults env_keep += "LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME"
Defaults env_keep += "LINES COLUMNS"
Defaults env_keep += "LSCOLORS"
Defaults env_keep += "SSH_AUTH_SOCK"
Defaults env_keep += "TZ"
Defaults env_keep += "DISPLAY XAUTHORIZATION XAUTHORITY"
Defaults env_keep += "EDITOR VISUAL"
Defaults env_keep += "HOME MAIL"

# Runas alias specification

# User privilege specification
root ALL=(ALL) ALL
%admin ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now

# Vagrant sudoers config
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /bin/sed -i -e /*/ d /etc/hosts
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE, VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE
10 changes: 10 additions & 0 deletions tasks/preferences.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@
changed_when: false
when: "'JJG-Term' not in terminal_theme.stdout"

# Sudoers configuration (enables more convenient Vagrant usage).
- name: Copy sudoers configuration into place.
copy:
src: files/etc/sudoers
dest: /etc/sudoers
mode: 0440
validate: 'visudo -cf %s'
sudo: yes
when: configure_sudoers

# TODO: Configure Sublime Text (see templates/sublime/*).
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
downloads: ~/.ansible-downloads/

configure_sudoers: yes

dotfiles_repo: https://github.com/geerlingguy/dotfiles.git
dotfiles_repo_local_destination: ~/Dropbox/Development/GitHub/dotfiles
dotfiles_files:
Expand Down

0 comments on commit cd63f37

Please sign in to comment.