From e0d6ead5f527ec2439c3cfc5025fad2e36c16488 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Thu, 5 Jul 2018 17:07:42 -0400 Subject: [PATCH 1/3] Rework home and add notes to sync.sh --- main.yml | 3 ++- roles/clean/tasks/main.yml | 11 +++++++++++ sync.sh | 26 +++++++++++++++----------- 3 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 roles/clean/tasks/main.yml diff --git a/main.yml b/main.yml index 890b8c3..9e5e01e 100644 --- a/main.yml +++ b/main.yml @@ -1,7 +1,7 @@ --- - hosts: all vars: - local_path: "{{ '~' | expanduser }}" + local_path: "{{ ansible_env.HOME }}" disable_passwordauth: false enable_passwordauth: false private_repo: "git@austenwares.com:stonewareslord/private" @@ -12,3 +12,4 @@ - {role: secure, become: yes, tags: [secure]} - {role: dns, tags: [dns]} - {role: private, tags: [private]} + - {role: clean, tags: [clean]} diff --git a/roles/clean/tasks/main.yml b/roles/clean/tasks/main.yml new file mode 100644 index 0000000..7e36379 --- /dev/null +++ b/roles/clean/tasks/main.yml @@ -0,0 +1,11 @@ +- name: Remove files + file: + path: "{{ local_path }}/{{ item.path }}" + state: absent + with_filetree: "skel/" +- name: Remove cloned repositories + file: + path: "{{ local_path }}/{{ item.path }}" + state: absent + loop: + - "{{ local_path }}/.fzf" diff --git a/sync.sh b/sync.sh index c2dc5ed..d626020 100755 --- a/sync.sh +++ b/sync.sh @@ -1,20 +1,24 @@ #!/bin/bash + +# Examples +# Secure SSH +# ./sync.sh secure --ask-become-pass --tags +# Disable SSH password authentication +# ./sync.sh secure --extra-vars 'disable_passwordauth=true' --ask-become-pass +# Use 1.1.1.1 dns +# ./sync.sh dns --ask-become-pass +# Sync for root +# ./sync.sh default,vim --become --ask-become-pass + \cd "$(dirname $0)" if [ -z "$1" ]; then echo "Usage:" - echo "$0 TAG1,TAG2" + echo "$0 TAG1[,TAG2] [ANSIBLE-OPTS]" echo "Available tags:" echo "$(\ls roles | tr '\n' ' ')" echo "Example: $0 default,vim" exit 1 fi -ansible-playbook -i 'localhost,' main.yml --tags $1 -# Could also sync vim: -# ansible-playbook -i hosts main.yml --tags default,vim -# vim +'call Initialize()' +'qa' -# Could also secure system -# ansible-playbook -i hosts --ask-become-pass main.yml --tags secure -# Disable password authentication -# ansible-playbook -i 'localhost,' --tags secure --extra-vars 'disable_passwordauth=true' main.yml --ask-become-pass -# Use 1.1.1.1 dns -# ansible-playbook -i 'localhost,' --tags dns main.yml --ask-become-pass +TAGS="$1" +shift +ansible-playbook -i 'localhost,' $* main.yml --tags "$TAGS" From 7dd3ac24fc698ddbd2cc914c4f4de2556324d426 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Thu, 5 Jul 2018 17:15:28 -0400 Subject: [PATCH 2/3] Make cleaning directory work properly --- README.md | 30 +++++++++++++++++++++++++----- roles/clean/tasks/main.yml | 5 +++-- sync.sh | 11 ----------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 1de2bbc..9f4a86d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,32 @@ -Sync -========= +# Sync + +### Examples +#### Delete everything in skel + + ./sync.sh clean + +#### Secure SSH + + ./sync.sh secure --ask-become-pass --tags + +#### Disable SSH password authentication + + ./sync.sh secure --extra-vars 'disable_passwordauth=true' --ask-become-pass + +#### Use 1.1.1.1 dns + + ./sync.sh dns --ask-become-pass + +#### Sync for root + + ./sync.sh default,vim --become --ask-become-pass Sync syncs tmux/vim/bash config files with one command -Usage: +Usage: usage: sync.sh [-h] [-t] [-c] [-b] [-s] [-d] - + optional arguements: -h Show this help message and exit -t Syncs tmux configuration file @@ -19,7 +39,7 @@ Or, install vim bundles and vimrc, customizing which bundles you use first (requ mkdir -p ~/.vim/plugin/ ~/.vim/backup/ ~/.vim/undo/ ~/.vim/tmp/ ~/.vim/bundle/ ~/.vim/bundle/ ; if [ ! -f ~/.vim/plugin/sessionman.vim ] ; then curl -o ~/.vim/plugin/sessionman.vim http://www.vim.org/scripts/download_script.php?src_id=15599 ; fi ; if [ ! -d ~/.vim/bundle/vundle/ ] ; then git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle ; fi ; curl -o ~/.vimrc -k https://austenwares.com/gitlab/stonewareslord/Sync/raw/master/vimrc ; vim ~/.vimrc +"execute \"normal /Bundle 'gmarik\/vundle'\\"" +"execute \"normal :nohlsearch\:function Save()\w\BundleInstall\qa\endfunction\\"" +"nnoremap :call Save():so ~/.vimrc:BundleInstall" ; echo "Installation should be complete. Run \"vim\" to check" -Usage: run this command and it will automatically load the bundle list with descriptions of each. Delete the ones you don't want to install and press `F2` in normal mode to install al at once. +Usage: run this command and it will automatically load the bundle list with descriptions of each. Delete the ones you don't want to install and press `F2` in normal mode to install al at once. Or, temporarily load the bashrc (requires `curl` package): diff --git a/roles/clean/tasks/main.yml b/roles/clean/tasks/main.yml index 7e36379..f52a5b9 100644 --- a/roles/clean/tasks/main.yml +++ b/roles/clean/tasks/main.yml @@ -5,7 +5,8 @@ with_filetree: "skel/" - name: Remove cloned repositories file: - path: "{{ local_path }}/{{ item.path }}" + path: "{{ local_path }}/{{ item }}" state: absent loop: - - "{{ local_path }}/.fzf" + - ".fzf" + - ".vim" diff --git a/sync.sh b/sync.sh index d626020..6748ff4 100755 --- a/sync.sh +++ b/sync.sh @@ -1,15 +1,4 @@ #!/bin/bash - -# Examples -# Secure SSH -# ./sync.sh secure --ask-become-pass --tags -# Disable SSH password authentication -# ./sync.sh secure --extra-vars 'disable_passwordauth=true' --ask-become-pass -# Use 1.1.1.1 dns -# ./sync.sh dns --ask-become-pass -# Sync for root -# ./sync.sh default,vim --become --ask-become-pass - \cd "$(dirname $0)" if [ -z "$1" ]; then echo "Usage:" From 0e928f9f34270c0b18b69419cbd70f29eb5af634 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Thu, 5 Jul 2018 17:18:54 -0400 Subject: [PATCH 3/3] Correctly order plug cleaning --- main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.yml b/main.yml index 9e5e01e..5225274 100644 --- a/main.yml +++ b/main.yml @@ -6,10 +6,10 @@ enable_passwordauth: false private_repo: "git@austenwares.com:stonewareslord/private" roles: + - {role: clean, tags: [clean]} - {role: core, tags: [default]} - {role: vim, tags: [vim]} - {role: youcompleteme, tags: [youcompleteme]} - {role: secure, become: yes, tags: [secure]} - {role: dns, tags: [dns]} - {role: private, tags: [private]} - - {role: clean, tags: [clean]}