[GIT] refactor submodules: add all to own repo

This commit is contained in:
Jannik Beyerstedt 2019-10-06 22:41:31 +02:00
commit 6ce42341b2
19 changed files with 328 additions and 0 deletions

36
README.md Normal file
View File

@ -0,0 +1,36 @@
Common
=========
Common user settings and tools.
Requirements
------------
none
Role Variables
--------------
TODO
Dependencies
------------
none
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
GPLv3

2
defaults/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# defaults file for common

2
handlers/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# handlers file for common

23
meta/main.yml Normal file
View File

@ -0,0 +1,23 @@
galaxy_info:
author: Jannik Beyerstedt
description: My personal common tasks and settings files
# issue_tracker_url: http://example.com/issue/tracker
license: GPLv3
min_ansible_version: 2.4
platforms:
- name: Debian
versions:
- all
- name: Darwin
versions:
- all
galaxy_tags: []
# List tags for your role here, one per line.
# Be sure to remove the '[]' above, if you add tags to this list.
dependencies: []
# List your role dependencies here, one per line.
# Be sure to remove the '[]' above, if you add tags to this list.

View File

@ -0,0 +1,14 @@
---
# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh) - macOS Version
- name: essentials - Install essential utilities
package:
name: "{{ packages }}"
state: latest
vars:
packages:
- git
- curl
- zsh
- vim
- tmux

View File

@ -0,0 +1,17 @@
---
# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh) - Debian Version
- name: essentials - Install essential utilities
become: yes
apt:
name: "{{ packages }}"
state: latest
update_cache: yes
cache_valid_time: 3600
vars:
packages:
- git
- curl
- zsh
- vim
- tmux

8
tasks/essentials.yml Normal file
View File

@ -0,0 +1,8 @@
---
# Common/Essentials: Essential Utilities (git, curl; vim, tmux, zsh)
- name: essentials - Install essential utilities
include_tasks: "{{ item }}"
with_first_found:
- "essentials-{{ ansible_distribution }}.yml"
- "essentials-{{ ansible_os_family }}.yml"

20
tasks/main.yml Normal file
View File

@ -0,0 +1,20 @@
---
# Common setup tasks for all nodes (universial)
# ATTENTION: This is just the maintenance version of the Common role. Run all
# tasks during setup in this order:
# - essentials
# - tools
# - usersetup
# - usersettings
- name: Install updates
import_tasks: update.yml
- name: Install essential tools
import_tasks: essentials.yml
- name: Install more tools
import_tasks: tools.yml
- name: Apply user settings
import_tasks: usersettings.yml

11
tasks/tools-Darwin.yml Normal file
View File

@ -0,0 +1,11 @@
---
# Common/Tools: Additional Tools (depending on OS) - macOS Version
- name: tools - Install basic utilities
homebrew:
name: "{{ packages }}"
state: latest
update_homebrew: yes
vars:
packages:
- rsync

17
tasks/tools-Debian.yml Normal file
View File

@ -0,0 +1,17 @@
---
# Common/Tools: Additional Tools (depending on OS) - Debian Version
- name: tools - Install basic utilities
become: yes
apt:
name: "{{ packages }}"
state: latest
update_cache: yes
cache_valid_time: 3600
vars:
packages:
- wget
- rsync
- htop
- unzip
# - dnsutils

8
tasks/tools.yml Normal file
View File

@ -0,0 +1,8 @@
---
# Common/Tools: Additional Tools (depending on OS)
- name: tools - Install basic utilities
include_tasks: "{{ item }}"
with_first_found:
- "tools-{{ ansible_distribution }}.yml"
- "tools-{{ ansible_os_family }}.yml"

7
tasks/update-Darwin.yml Normal file
View File

@ -0,0 +1,7 @@
---
# Common/Update: Install All Updates - macOS Version
- name: update - Update and upgrade all packages
homebrew:
update_homebrew: yes
upgrade_all: yes

12
tasks/update-Debian.yml Normal file
View File

@ -0,0 +1,12 @@
---
# Common/Update: Install All Updates - Debian Version
- name: update - Update and upgrade all packages
become: yes
apt:
force_apt_get: true
name: "*"
state: latest
update_cache: yes
autoclean: yes
autoremove: yes

8
tasks/update.yml Normal file
View File

@ -0,0 +1,8 @@
---
# Common/Update: Install All Updates
- name: update - Update and upgrade all packages
include_tasks: "{{ item }}"
with_first_found:
- "update-{{ ansible_distribution }}.yml"
- "update-{{ ansible_os_family }}.yml"

41
tasks/usersettings.yml Normal file
View File

@ -0,0 +1,41 @@
---
# Common/Usersettings: Universial Dotfiles. Update regularly.
- name: usersettings - Install/ Update oh-my-zsh for jannik
git:
repo: https://github.com/robbyrussell/oh-my-zsh.git
dest: .oh-my-zsh
- name: usersettings - Install/ Update fzf sources
git:
repo: https://github.com/junegunn/fzf.git
dest: .fzf
register:
fzf_git
- name: (Re-)Install fzf
shell: ".fzf/install --key-bindings --no-completion --no-update-rc"
when:
- fzf_git.after != fzf_git.before
- name: usersettings - Copy dotfiles
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
- { src: '{{ role_path }}/files/dotfiles/_gitconfig', dest: '.gitconfig' }
- { src: '{{ role_path }}/files/dotfiles/_gitignore_global', dest: '.gitignore_global' }
- { src: '{{ role_path }}/files/dotfiles/_tmux.conf', dest: '.tmux.conf' }
- { src: '{{ role_path }}/files/dotfiles/_vimrc', dest: '.vimrc' }
- { src: '{{ role_path }}/files/dotfiles/_zshrc', dest: '.zshrc' }
- { src: '{{ role_path }}/files/dotfiles/_oh-my-zsh/custom/themes/agnoster.zsh-theme', dest: '.oh-my-zsh/custom/themes/agnoster.zsh-theme' }
- name: usersettings - Install vim plugins
git:
repo: "{{ item.repo }}"
dest: "{{ item.dest }}"
with_items:
- { repo: 'https://github.com/itchyny/lightline.vim', dest: '.vim/bundle/lightline' }
- { repo: 'https://github.com/w0rp/ale', dest: '.vim/bundle/ale' }
- { repo: 'https://github.com/airblade/vim-gitgutter', dest: '.vim/bundle/vim-gitgutter' }
- { repo: 'https://github.com/sheerun/vim-polyglot', dest: '.vim/bundle/vim-polyglot' }
- { repo: 'https://github.com/tpope/vim-commentary', dest: '.vim/bundle/vim-commentary' }

View File

@ -0,0 +1,38 @@
---
# Common/Usersetup: Auto-setup a user shell and prepare dotfiles - macOS Version
# Will run once per user, because of lockfile `~/.ansbl-common-usersetup`
- name: usersetup - Check, if usersetup already ran
stat:
path: .ansbl-common-usersetup
register:
common_usersetup
- name: usersetup - Change login shell to zsh for current user
become: yes
user:
name: "{{ ansible_user_id }}"
shell: /bin/zsh
when:
- common_usersetup.stat.exists == false
- name: usersetup - Create .vim directory
file:
path: .vim/autoload
state: directory
when:
- common_usersetup.stat.exists == false
- name: usersetup - Install vim plugin manager
get_url:
url: https://tpo.pe/pathogen.vim
dest: .vim/autoload/pathogen.vim
when:
- common_usersetup.stat.exists == false
- name: usersetup - Create lockfile
file:
path: .ansbl-common-usersetup
state: touch
when:
- common_usersetup.stat.exists == false

View File

@ -0,0 +1,53 @@
---
# Common/Usersetup: Auto-setup a user shell and prepare dotfiles - Debian Version
# Will run once per user, because of lockfile `~/.ansbl-common-usersetup`
- name: usersetup - Check, if usersetup already ran
stat:
path: .ansbl-common-usersetup
register:
common_usersetup
- name: usersetup - Change login shell to zsh for current user
become: yes
user:
name: "{{ ansible_user_id }}"
shell: /bin/zsh
when:
- common_usersetup.stat.exists == false
- name: usersetup - Create .vim directory
file:
path: .vim/autoload
state: directory
when:
- common_usersetup.stat.exists == false
- name: usersetup - Install vim plugin manager
get_url:
url: https://tpo.pe/pathogen.vim
dest: .vim/autoload/pathogen.vim
when:
- common_usersetup.stat.exists == false
- name: usersetup - Setup locale en_US
become: yes
locale_gen:
name: en_US.UTF-8
state: present
when:
- common_usersetup.stat.exists == false
- name: usersetup - Setup locale de_DE
become: yes
locale_gen:
name: de_DE.UTF-8
state: present
when:
- common_usersetup.stat.exists == false
- name: usersetup - Create lockfile
file:
path: .ansbl-common-usersetup
state: touch
when:
- common_usersetup.stat.exists == false

9
tasks/usersetup.yml Normal file
View File

@ -0,0 +1,9 @@
---
# Common/Usersetup: Auto-setup a user shell and prepare dotfiles.
# Will run once per user, because of lockfile `~/.ansbl-common-usersetup`
- name: usersetup - Run setup tasks
include_tasks: "{{ item }}"
with_first_found:
- "usersetup-{{ ansible_distribution }}.yml"
- "usersetup-{{ ansible_os_family }}.yml"

2
vars/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# vars file for common