commit 6ce42341b2fd0fe36737e6f72d4dbc33204af5eb Author: Jannik Beyerstedt Date: Sun Oct 6 22:41:31 2019 +0200 [GIT] refactor submodules: add all to own repo diff --git a/README.md b/README.md new file mode 100644 index 0000000..3d2cd7f --- /dev/null +++ b/README.md @@ -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 diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..205c4a1 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for common diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..2662adc --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for common diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..2cb07c3 --- /dev/null +++ b/meta/main.yml @@ -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. diff --git a/tasks/essentials-Darwin.yml b/tasks/essentials-Darwin.yml new file mode 100644 index 0000000..4905a36 --- /dev/null +++ b/tasks/essentials-Darwin.yml @@ -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 diff --git a/tasks/essentials-Debian.yml b/tasks/essentials-Debian.yml new file mode 100644 index 0000000..887d1da --- /dev/null +++ b/tasks/essentials-Debian.yml @@ -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 diff --git a/tasks/essentials.yml b/tasks/essentials.yml new file mode 100644 index 0000000..98bbfab --- /dev/null +++ b/tasks/essentials.yml @@ -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" diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..cea198d --- /dev/null +++ b/tasks/main.yml @@ -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 diff --git a/tasks/tools-Darwin.yml b/tasks/tools-Darwin.yml new file mode 100644 index 0000000..f922d2a --- /dev/null +++ b/tasks/tools-Darwin.yml @@ -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 diff --git a/tasks/tools-Debian.yml b/tasks/tools-Debian.yml new file mode 100644 index 0000000..06d7f30 --- /dev/null +++ b/tasks/tools-Debian.yml @@ -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 diff --git a/tasks/tools.yml b/tasks/tools.yml new file mode 100644 index 0000000..396ac77 --- /dev/null +++ b/tasks/tools.yml @@ -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" diff --git a/tasks/update-Darwin.yml b/tasks/update-Darwin.yml new file mode 100644 index 0000000..d267668 --- /dev/null +++ b/tasks/update-Darwin.yml @@ -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 diff --git a/tasks/update-Debian.yml b/tasks/update-Debian.yml new file mode 100644 index 0000000..5ffd831 --- /dev/null +++ b/tasks/update-Debian.yml @@ -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 diff --git a/tasks/update.yml b/tasks/update.yml new file mode 100644 index 0000000..dda7b59 --- /dev/null +++ b/tasks/update.yml @@ -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" diff --git a/tasks/usersettings.yml b/tasks/usersettings.yml new file mode 100644 index 0000000..d37fbf8 --- /dev/null +++ b/tasks/usersettings.yml @@ -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' } diff --git a/tasks/usersetup-Darwin.yml b/tasks/usersetup-Darwin.yml new file mode 100644 index 0000000..3965c5f --- /dev/null +++ b/tasks/usersetup-Darwin.yml @@ -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 diff --git a/tasks/usersetup-Debian.yml b/tasks/usersetup-Debian.yml new file mode 100644 index 0000000..035dfe1 --- /dev/null +++ b/tasks/usersetup-Debian.yml @@ -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 diff --git a/tasks/usersetup.yml b/tasks/usersetup.yml new file mode 100644 index 0000000..e440fe0 --- /dev/null +++ b/tasks/usersetup.yml @@ -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" diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..feaa92f --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for common \ No newline at end of file