From 2e0a6073c833ba4350c816ccfe1be014e5907fa0 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 27 Oct 2022 00:07:06 -0400 Subject: [PATCH] Add more config files to the base role. --- ansible/environments/laptop/group_vars/all | 1 + .../environments/laptop/host_vars/odofreebsd | 1 + .../environments/laptop/host_vars/odolinux | 1 + .../base/files/git_branches_by_owner_time | 11 ++++++++ ansible/roles/base/files/gitconfig_home | 15 +++++++++++ ansible/roles/base/files/gitignore_global | 2 ++ ansible/roles/base/files/ignore | 0 ansible/roles/base/files/tmux.conf | 8 ++++++ ansible/roles/base/tasks/freebsd.yaml | 19 +++++++++++++ ansible/roles/base/tasks/peruser.yaml | 27 +++++++++++++++++++ 10 files changed, 85 insertions(+) create mode 100644 ansible/environments/laptop/group_vars/all create mode 100644 ansible/roles/base/files/git_branches_by_owner_time create mode 100644 ansible/roles/base/files/gitconfig_home create mode 100644 ansible/roles/base/files/gitignore_global create mode 100644 ansible/roles/base/files/ignore create mode 100644 ansible/roles/base/files/tmux.conf diff --git a/ansible/environments/laptop/group_vars/all b/ansible/environments/laptop/group_vars/all new file mode 100644 index 0000000..d3471aa --- /dev/null +++ b/ansible/environments/laptop/group_vars/all @@ -0,0 +1 @@ +timezone: "America/New_York" diff --git a/ansible/environments/laptop/host_vars/odofreebsd b/ansible/environments/laptop/host_vars/odofreebsd index 4d4373d..4149cfa 100644 --- a/ansible/environments/laptop/host_vars/odofreebsd +++ b/ansible/environments/laptop/host_vars/odofreebsd @@ -31,3 +31,4 @@ users: - main_fido - backup_fido - homeassistant +gitconfig: gitconfig_home diff --git a/ansible/environments/laptop/host_vars/odolinux b/ansible/environments/laptop/host_vars/odolinux index f3b011a..267767c 100644 --- a/ansible/environments/laptop/host_vars/odolinux +++ b/ansible/environments/laptop/host_vars/odolinux @@ -21,3 +21,4 @@ graphics_driver: "intel" build_user: name: talexander group: talexander +gitconfig: gitconfig_home diff --git a/ansible/roles/base/files/git_branches_by_owner_time b/ansible/roles/base/files/git_branches_by_owner_time new file mode 100644 index 0000000..168c784 --- /dev/null +++ b/ansible/roles/base/files/git_branches_by_owner_time @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# +# List git remote branches by owner +#git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n + +# git fetch --all --prune +# git for-each-ref --format='%(committerdate:relative) %09 %(authorname) %09 %(refname)' --sort='committerdate' | grep 'Tom Alexander' + +git ls-remote --heads origin | awk '{print $1}' | while read hash; do + PAGER='' git log -n1 --pretty=format:'%Cgreen%<(20)%cr%Creset %C(bold blue)%<(20)%an%Creset %C(yellow)%d%Creset %n' "$hash" +done diff --git a/ansible/roles/base/files/gitconfig_home b/ansible/roles/base/files/gitconfig_home new file mode 100644 index 0000000..5bcd33f --- /dev/null +++ b/ansible/roles/base/files/gitconfig_home @@ -0,0 +1,15 @@ +[user] + email = tom@fizz.buzz + name = Tom Alexander + signingkey = D3A179C9A53C0EDE +[push] + default = simple +[alias] + lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit + bh = log --oneline --branches=* --remotes=* --graph --decorate +[core] + excludesfile = /home/talexander/.gitignore_global +[commit] + gpgsign = true +[pull] + rebase = true diff --git a/ansible/roles/base/files/gitignore_global b/ansible/roles/base/files/gitignore_global new file mode 100644 index 0000000..e0809b4 --- /dev/null +++ b/ansible/roles/base/files/gitignore_global @@ -0,0 +1,2 @@ +.idea +.python-version diff --git a/ansible/roles/base/files/ignore b/ansible/roles/base/files/ignore new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/base/files/tmux.conf b/ansible/roles/base/files/tmux.conf new file mode 100644 index 0000000..652a43d --- /dev/null +++ b/ansible/roles/base/files/tmux.conf @@ -0,0 +1,8 @@ +set-option -g mouse on +set-option -g history-limit 20000 +# set -g @plugin 'tmux-plugins/tmux-yank' +# Emacs style +# bind-key -T copy-mode y send-key -X copy-pipe-and-cancel "xsel -i -p && xsel -o -p | xsel -i -b" +# bind-key -T copy-mode y send-key -X copy-pipe "xsel -i -p && xsel -o -p | xsel -i -b" +# bind-key C-y run "xsel -o | tmux load-buffer - ; tmux paste-buffer" +# unbind -T copy-mode MouseDragEnd1Pane diff --git a/ansible/roles/base/tasks/freebsd.yaml b/ansible/roles/base/tasks/freebsd.yaml index 3d0b293..371211e 100644 --- a/ansible/roles/base/tasks/freebsd.yaml +++ b/ansible/roles/base/tasks/freebsd.yaml @@ -104,3 +104,22 @@ src: tmpfs fstype: tmpfs opts: rw,mode=777 + +- name: Set timezone + file: + src: "/usr/share/zoneinfo/{{ timezone|default('UTC') }}" + dest: /etc/localtime + owner: root + group: wheel + state: link + +- name: Install scripts + copy: + src: "files/{{ item.src }}" + dest: "{{ item.dest }}" + mode: 0755 + owner: root + group: wheel + loop: + - src: git_branches_by_owner_time + dest: /usr/local/bin/git_branches_by_owner_time diff --git a/ansible/roles/base/tasks/peruser.yaml b/ansible/roles/base/tasks/peruser.yaml index da9386d..183ff7a 100644 --- a/ansible/roles/base/tasks/peruser.yaml +++ b/ansible/roles/base/tasks/peruser.yaml @@ -1,6 +1,33 @@ - include_role: name: per_user +- name: Configure gitconfig + copy: + src: "files/{{ item.src }}" + dest: "{{ account_homedir.stdout }}/{{ item.dest }}" + mode: 0600 + owner: "{{ account_name.stdout }}" + group: "{{ group_name.stdout }}" + when: gitconfig is defined + loop: + - src: "{{ gitconfig }}" + dest: .gitconfig + +- name: Copy files + copy: + src: "files/{{ item.src }}" + dest: "{{ account_homedir.stdout }}/{{ item.dest }}" + mode: 0600 + owner: "{{ account_name.stdout }}" + group: "{{ group_name.stdout }}" + loop: + - src: ignore + dest: .ignore + - src: tmux.conf + dest: .tmux.conf + - src: gitignore_global + dest: .gitignore_global + - import_tasks: tasks/peruser_freebsd.yaml when: 'os_flavor == "freebsd"'