From e0d6ead5f527ec2439c3cfc5025fad2e36c16488 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Thu, 5 Jul 2018 17:07:42 -0400 Subject: [PATCH] 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"