Skip to content

Commit

Permalink
Merge pull request #5 from brabster/add-gitmain-alias
Browse files Browse the repository at this point in the history
Add new git-related aliases, maybe better vars solution
  • Loading branch information
brabster authored Jan 23, 2024
2 parents aa64899 + 204fc40 commit a733611
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 13 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/test_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ jobs:
- name: checkout
uses: actions/checkout@v3
- name: setup
run: >
cd $GITHUB_WORKSPACE && ansible-playbook -e in_container=true workstation.yml --extra-vars 'git_name="Testy McTestface" username=tester git_email="[email protected]"'
run: |
cd $GITHUB_WORKSPACE
cp ${GITHUB_WORKSPACE}/.github/workflows/test_vars.yml ${GITHUB_WORKSPACE}/.vars.yml
ansible-playbook -e in_container=true workstation.yml
- name: check
shell: bash -l {0}
run: |
su - tester -c "git config --list"
su - tester -c "python --version"
su - tester -c "clamscan --version"
shell: bash


su - tester
alias
git config --list
python --version
clamscan --version
3 changes: 3 additions & 0 deletions .github/workflows/test_vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
git_name: Testy McTestface
git_email: [email protected]
username: tester
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vars.yml
3 changes: 3 additions & 0 deletions .vars_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
git_name: Your name
git_email: your email
username: your system username
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo "=== Cloning repo into $(pwd)"
git clone https://github.com/brabster/xubuntu-workstation.git

echo "=== cd into xubuntu-workstation.."
echo "=== Update undefined vars.yml (or pass --extra-vars arg on next instruction)"
echo "=== Create gitignored .vars.yml with undefined form vars.yml (or pass --extra-vars arg on next instruction)"
echo "=== Then run ansible-playbook workstation.yml"
echo "=== Finally, log out and in again, no need to reboot."

10 changes: 10 additions & 0 deletions roles/git/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@
marker: '# {mark} ANSIBLE_GIT'
block: |
source /usr/share/bash-completion/completions/git
- name: Setup bash aliases
become: yes
become_user: '{{ username }}'
blockinfile:
path: '{{ user_bashrc }}'
marker: '# {mark} GIT_ALIAS'
block: |
alias gitdefault="git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'"
alias gitmain="git switch $(gitdefault) && git pull && git branch | grep -v $(gitdefault) | xargs -r git branch -D"
3 changes: 2 additions & 1 deletion test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
- hosts: localhost
vars_files:
- ./.vars.yml
- ./vars.yml
roles:
- role: ./roles/clamav
- role: ./roles/git



Expand Down
7 changes: 4 additions & 3 deletions vars.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
git_name: '{{ undef(hint="git_name must be set to the value for git config value user.name") }}'
git_email: '{{ undef(hint="git_email must be set to the value for git config value user.email") }}'
username: '{{ undef(hint="username must be set to OS user username") }}'
# install-specific, set these in .vars.yml
# git_name: '{{ undef(hint="git_name must be set to the value for git config value user.name") }}'
# git_email: '{{ undef(hint="git_email must be set to the value for git config value user.email") }}'
# username: '{{ undef(hint="username must be set to OS user username") }}'
user_home: '/home/{{ username }}'
user_bashrc: '{{ user_home }}/.bashrc'
user_profile: '{{ user_home }}/.profile'
Expand Down
1 change: 1 addition & 0 deletions workstation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- hosts: localhost
become_method: sudo
vars_files:
- ./.vars.yml
- ./vars.yml
roles:
- role: ./roles/sudo
Expand Down

0 comments on commit a733611

Please sign in to comment.