home · contact · privacy
Ansible experiment: add user script.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 18 Mar 2017 10:51:11 +0000 (11:51 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 18 Mar 2017 10:51:11 +0000 (11:51 +0100)
17 files changed:
ansible/config.yml
ansible/files/dotfiles/bashrc [deleted file]
ansible/files/dotfiles/gitconfig [deleted file]
ansible/files/dotfiles/minimal/bashrc [new file with mode: 0644]
ansible/files/dotfiles/minimal/gitconfig [new file with mode: 0644]
ansible/files/dotfiles/minimal/profile [new file with mode: 0644]
ansible/files/dotfiles/minimal/shinit [new file with mode: 0644]
ansible/files/dotfiles/minimal/vimrc [new file with mode: 0644]
ansible/files/dotfiles/profile [deleted file]
ansible/files/dotfiles/root/shinit_color [new file with mode: 0644]
ansible/files/dotfiles/root/vimrc_add [new file with mode: 0644]
ansible/files/dotfiles/shinit [deleted file]
ansible/files/dotfiles/shinit_color [deleted file]
ansible/files/dotfiles/vimrc [deleted file]
ansible/files/dotfiles/vimrc_add [deleted file]
ansible/run_user.sh [new file with mode: 0644]
ansible/user.yml [new file with mode: 0644]

index b34b52940118653ad03a85f2212a94af8a74a1cf..5ae4a3a7bde56a9beb238dc1839bf98d8847f52a 100644 (file)
     command: setupcon
 
   # Miscellaneous.
-  - name: Ensure dotfile symlinks
+  - name: Ensure minimal dotfile symlinks
     file: state=link force=yes src={{item}} dest=~/.{{item|basename}}
-    with_fileglob: ~/config/ansible/files/dotfiles/*
+    with_fileglob: ~/config/ansible/files/dotfiles/minimal/*
+  - name: Ensure root user dotfile symlinks
+    file: state=link force=yes src={{item}} dest=~/.{{item|basename}}
+    with_fileglob: ~/config/ansible/files/dotfiles/root/*
   - name: ensure ~/.vimbackups directory
     file: state=directory dest=~/.vimbackups
   - name: ensure man-db, manpages is installed
     - manpages
   - name: set /etc/localtime
     file: state=link force=yes src=/usr/share/zoneinfo/Europe/Berlin dest=/etc/localtime
-  - name: ensure git, vim, less are installed
+  - name: ensure sudo, git, vim, less are installed
     apt: name={{item}} state=present
     with_items:
     - git
     - vim
     - less
-  - name: create user plom
-    user: name=plom
+    - sudo
   - name: ensure boot messages are not cleared on start up
     replace: dest=/etc/systemd/system/getty.target.wants/getty@tty1.service regexp='^TTYVTDisallocate=yes.*$' replace='TTYVDisallocate=no'
+
+  # Config user.
+  - name: create user plom
+    user: name=plom
+  - name: have config repo in user directory
+    git: repo=git://github.com/plomlompom/config dest=/home/plom/config
+    become_user: plom
+    become_method: su
+  - name: ensure user has sudo privileges
+    command: adduser plom sudo
diff --git a/ansible/files/dotfiles/bashrc b/ansible/files/dotfiles/bashrc
deleted file mode 100644 (file)
index 4dc08f7..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-# Bash as a non-login shell in non-POSIX-mode does not read in the startup
-# script at the path in $ENV. This forces it to still read in the ~/.shinit
-# startup script for non-login shells.
-
-. ~/.shinit
diff --git a/ansible/files/dotfiles/gitconfig b/ansible/files/dotfiles/gitconfig
deleted file mode 100644 (file)
index 5cdc162..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-[user]
-       name = Christian Heller
-       email = c.heller@plomlompom.de
diff --git a/ansible/files/dotfiles/minimal/bashrc b/ansible/files/dotfiles/minimal/bashrc
new file mode 100644 (file)
index 0000000..4dc08f7
--- /dev/null
@@ -0,0 +1,5 @@
+# Bash as a non-login shell in non-POSIX-mode does not read in the startup
+# script at the path in $ENV. This forces it to still read in the ~/.shinit
+# startup script for non-login shells.
+
+. ~/.shinit
diff --git a/ansible/files/dotfiles/minimal/gitconfig b/ansible/files/dotfiles/minimal/gitconfig
new file mode 100644 (file)
index 0000000..5cdc162
--- /dev/null
@@ -0,0 +1,3 @@
+[user]
+       name = Christian Heller
+       email = c.heller@plomlompom.de
diff --git a/ansible/files/dotfiles/minimal/profile b/ansible/files/dotfiles/minimal/profile
new file mode 100644 (file)
index 0000000..5a58435
--- /dev/null
@@ -0,0 +1,6 @@
+# Initialization for login shells.
+
+# Tell interactive shells to look in ~/.shinit for setup.
+ENV=$HOME/.shinit
+export ENV
+. $ENV
diff --git a/ansible/files/dotfiles/minimal/shinit b/ansible/files/dotfiles/minimal/shinit
new file mode 100644 (file)
index 0000000..25d1396
--- /dev/null
@@ -0,0 +1,37 @@
+# Settings for interactive shells.
+
+# Ensure shell truly is interactive to avoid confusing non-interactive shells.
+if [[ $- == *i* ]]; then
+
+    # Fancy colors for ls.
+    alias ls="ls --color=auto"
+
+    # Use vim as default editor for anything.
+    export VISUAL=vim
+    export EDITOR=$VISUAL
+
+    # Colored prompt with username, hostname, date/time, directory.
+    colornumber=7 # Default to white if no color set via colornumber dotfile.
+    colornumber_file=~/.shinit_color
+    if [ -f $colornumber_file ]; then
+        colornumber=`cat $colornumber_file`
+    fi
+    tput_color="$(tput setaf $colornumber)$(tput bold)"
+    tput_reset="$(tput sgr0)"
+    # Bash confuses the line length when not told to not count escape sequences.
+    if [ ! "$BASH" = "" ]; then
+        tput_color="\[$tput_color\]"
+        tput_reset="\[$tput_reset\]"
+    fi
+    PS1="${tput_color}["\$\(date\ +%Y-%m-%d/%H:%M:%S/%Z\)" $USER@$(hostname):"\$\(pwd\)"]$ $tput_reset"
+    PS2="${tput_color}> $tput_reset"
+    PS3="${tput_color}select: $tput_reset"
+    PS4="${tput_color}+ $tput_reset"
+
+    # Add local additions.
+    local_shinit_file=~/.shinit_add
+    if [ -f $local_shinit_file ]; then
+        . $local_shinit_file
+    fi
+
+fi
diff --git a/ansible/files/dotfiles/minimal/vimrc b/ansible/files/dotfiles/minimal/vimrc
new file mode 100644 (file)
index 0000000..b1434ed
--- /dev/null
@@ -0,0 +1,30 @@
+" Activate syntax highlighting.
+syntax on
+filetype plugin on
+
+" Number lines.
+set number
+
+" Don't add unsolicited final newline.
+set binary
+
+" Indentation rules (tabs to 4 spaces).
+set expandtab
+set shiftwidth=2
+set softtabstop=2
+
+" Backups.
+set backup
+set backupdir=~/.vimbackups
+let myvar = strftime("%Y-%m-%d_%H-%M-%S")
+let myvar = "set backupext=_". myvar
+execute myvar
+
+" Keep syntax highlighting healthy.
+autocmd BufEnter * :syntax sync fromstart
+
+" Mark the 80-th column.
+set colorcolumn=80
+
+" Source additions
+source ~/.vimrc_add
diff --git a/ansible/files/dotfiles/profile b/ansible/files/dotfiles/profile
deleted file mode 100644 (file)
index 5a58435..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Initialization for login shells.
-
-# Tell interactive shells to look in ~/.shinit for setup.
-ENV=$HOME/.shinit
-export ENV
-. $ENV
diff --git a/ansible/files/dotfiles/root/shinit_color b/ansible/files/dotfiles/root/shinit_color
new file mode 100644 (file)
index 0000000..d00491f
--- /dev/null
@@ -0,0 +1 @@
+1
diff --git a/ansible/files/dotfiles/root/vimrc_add b/ansible/files/dotfiles/root/vimrc_add
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/ansible/files/dotfiles/shinit b/ansible/files/dotfiles/shinit
deleted file mode 100644 (file)
index 25d1396..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# Settings for interactive shells.
-
-# Ensure shell truly is interactive to avoid confusing non-interactive shells.
-if [[ $- == *i* ]]; then
-
-    # Fancy colors for ls.
-    alias ls="ls --color=auto"
-
-    # Use vim as default editor for anything.
-    export VISUAL=vim
-    export EDITOR=$VISUAL
-
-    # Colored prompt with username, hostname, date/time, directory.
-    colornumber=7 # Default to white if no color set via colornumber dotfile.
-    colornumber_file=~/.shinit_color
-    if [ -f $colornumber_file ]; then
-        colornumber=`cat $colornumber_file`
-    fi
-    tput_color="$(tput setaf $colornumber)$(tput bold)"
-    tput_reset="$(tput sgr0)"
-    # Bash confuses the line length when not told to not count escape sequences.
-    if [ ! "$BASH" = "" ]; then
-        tput_color="\[$tput_color\]"
-        tput_reset="\[$tput_reset\]"
-    fi
-    PS1="${tput_color}["\$\(date\ +%Y-%m-%d/%H:%M:%S/%Z\)" $USER@$(hostname):"\$\(pwd\)"]$ $tput_reset"
-    PS2="${tput_color}> $tput_reset"
-    PS3="${tput_color}select: $tput_reset"
-    PS4="${tput_color}+ $tput_reset"
-
-    # Add local additions.
-    local_shinit_file=~/.shinit_add
-    if [ -f $local_shinit_file ]; then
-        . $local_shinit_file
-    fi
-
-fi
diff --git a/ansible/files/dotfiles/shinit_color b/ansible/files/dotfiles/shinit_color
deleted file mode 100644 (file)
index d00491f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/ansible/files/dotfiles/vimrc b/ansible/files/dotfiles/vimrc
deleted file mode 100644 (file)
index b1434ed..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-" Activate syntax highlighting.
-syntax on
-filetype plugin on
-
-" Number lines.
-set number
-
-" Don't add unsolicited final newline.
-set binary
-
-" Indentation rules (tabs to 4 spaces).
-set expandtab
-set shiftwidth=2
-set softtabstop=2
-
-" Backups.
-set backup
-set backupdir=~/.vimbackups
-let myvar = strftime("%Y-%m-%d_%H-%M-%S")
-let myvar = "set backupext=_". myvar
-execute myvar
-
-" Keep syntax highlighting healthy.
-autocmd BufEnter * :syntax sync fromstart
-
-" Mark the 80-th column.
-set colorcolumn=80
-
-" Source additions
-source ~/.vimrc_add
diff --git a/ansible/files/dotfiles/vimrc_add b/ansible/files/dotfiles/vimrc_add
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/ansible/run_user.sh b/ansible/run_user.sh
new file mode 100644 (file)
index 0000000..e52b521
--- /dev/null
@@ -0,0 +1 @@
+ansible-playbook -i 'localhost,' -c local user.yml
diff --git a/ansible/user.yml b/ansible/user.yml
new file mode 100644 (file)
index 0000000..a34f6fe
--- /dev/null
@@ -0,0 +1,11 @@
+- hosts: all
+  tasks:
+
+  - name: ensure ~/.vimbackups directory
+    file: state=directory dest=~/.vimbackups
+  - name: Ensure dotfile symlinks
+    file: state=link force=yes src={{item}} dest=~/.{{item|basename}}
+    with_fileglob: ~/config/ansible/files/dotfiles/minimal/*
+  - name: Ensure user dotfile symlinks
+    file: state=link force=yes src={{item}} dest=~/.{{item|basename}}
+    with_fileglob: ~/config/ansible/files/dotfiles/user/*