Skip to content

Commit

Permalink
Remove useless parts and upgrade to Ansible2
Browse files Browse the repository at this point in the history
  • Loading branch information
mpailloncy committed Oct 10, 2016
1 parent 07ce563 commit 5579d34
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 211 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vault-password
*.vault
*.retry
4 changes: 0 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
---

proxy_env:
http_proxy: ""
https_proxy: ""
2 changes: 0 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---

- name: reload systemd configuration
sudo: yes
shell: systemctl daemon-reload

- name: restart docker
sudo: yes
service: name=docker state=restarted
2 changes: 2 additions & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- hosts: 127.0.0.1
connection: local
become: yes
become_method: sudo
roles:
- { role: resetenv }
2 changes: 1 addition & 1 deletion resetenv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

currentDir=$( cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P )
ansible-playbook -i $currentDir/hosts --vault-password-file=$currentDir/.vault-password $currentDir/playbook.yml -e resetenv_path=$currentDir $@
ansible-playbook -i $currentDir/hosts $currentDir/playbook.yml -e resetenv_path=$currentDir $@
143 changes: 17 additions & 126 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,31 @@
- include_vars: common-vars.yml.vault
tags:
- fast
- ssh

- name: Check that the current machine is a Fedora 22
assert: { that: "ansible_distribution == 'Fedora' and ansible_distribution_version == '22'" }

###############################################################################################
# Work part
#
- name: at work ?
shell: "ping -c1 -i 0.2 {{ pingued.host }}"
register: i_am_at_work
ignore_errors: yes
changed_when: false
tags: fast

- name: check if I'm at work
set_fact: at_work={{ true if i_am_at_work.rc == 0 else false }}
tags: fast

- debug: var=at_work

- include_vars: work-vars.yml.vault
when: at_work == true
tags: fast

###############################################################################################
# dnf configuration
#
- name: add dnf conf file
template: src=dnf.conf owner=root group=root dest=/etc/dnf/dnf.conf mode=644
tags: fast
sudo: yes
- name: Check that the current machine is a Fedora 24
assert: { that: "ansible_distribution == 'Fedora' and ansible_distribution_version == '24'" }

###############################################################################################
# install packages
#
- { include: get-and-cache.yml, toget: "http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-22.noarch.rpm" }
- { include: get-and-cache.yml, toget: "http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-24.noarch.rpm" }

- name: Install RPMFusion free repository
sudo: yes
dnf: name="{{ cached }}" state=present
tags: rpmfusion

- { include: get-and-cache.yml, toget: "http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-22.noarch.rpm" }
- { include: get-and-cache.yml, toget: "http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-24.noarch.rpm" }

- name: Install RPMFusion non-free repository
sudo: yes
dnf: name="{{ cached }}" state=present
tags: rpmfusion

- name: install packages
sudo: yes
dnf: name={{ item }} state=present
with_items:
- zsh
- libselinux-python
- git
- git-svn
- git-gui
- tig
- subversion
- tree
- unzip
- vagrant
Expand All @@ -71,12 +36,9 @@
- java-1.8.0-openjdk-devel
- groovy
- ntpdate
- rubygem-asciidoctor
- tmux
- tmuxinator
- keepass
- gimp
- baobab
- vlc
- powerline
- tmux-powerline
Expand All @@ -85,51 +47,25 @@
###############################################################################################
# Docker
#
- include: docker.yml

###############################################################################################
# ssh configuration
#
- include_vars: sshconfig.yml.vault
tags: ssh

- name: remove current ssh config file
file:
path="{{ user.home }}/.ssh/config"
state=absent
changed_when: false
tags: ssh

- name: generate ~/.ssh/config
lineinfile:
dest="{{ user.home }}/.ssh/config"
line="{{ item.value }}"
state=present
insertafter=EOF
create=yes
owner="{{ user.name }}"
group="{{ user.name }}"
mode=0700
with_dict: sshconfig.hosts
changed_when: false
tags: ssh
# - include: docker.yml

###############################################################################################
# tools settings
#
- name: Set Git autosquash true globally (todo => idempotentize)
shell: git config --global rebase.autosquash true
changed_when: false

- name: configure git
shell: >
git config --global user.email '{{ user.email }}' &&
git config --global user.name '{{ user.fullName }}'
changed_when: false
tags: fast
- name: configure git name
git_config:
name=user.name
scope=system
value="{{ user.fullName }}"

- name: configure git email
git_config:
name=user.email
scope=system
value="{{ user.email }}"

- name: set default shell to zsh
sudo: yes
user: name={{ user.name }} shell=/usr/bin/zsh state=present

- name: install oh-my-zsh
Expand All @@ -147,79 +83,34 @@

- name: add zshrc file
template: src=zshrc owner={{ user.name }} group={{ user.name }} dest={{ user.home }}/.zshrc mode=644
tags: fast

- name: add tmux config file (powerline)
template: src=tmux.conf owner={{ user.name }} group={{ user.name }} dest={{ user.home }}/.tmux.conf mode=644
tags: fast

- name: add tmuxinator-completion file for zsh
copy: src=tmuxinator-completion.zsh owner={{ user.name }} group={{ user.name }} dest={{ user.home }}/.tmuxinator-completion.zsh mode=644

- name: create tmuxinator config directories
file: path={{ user.home }}/.tmuxinator owner={{ user.name }} group={{ user.name }} state=directory
tags: fast

- name: add tmuxinator config file
template: src=tmuxinator/work.yml owner={{ user.name }} group={{ user.name }} dest={{ user.home }}/.tmuxinator/work.yml
tags: fast

- name: add vimrc file
template: src=vimrc owner={{ user.name }} group={{ user.name }} dest={{ user.home }}/.vimrc mode=644

- { include: get-and-cache.yml, toget: "http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3083_x64.tar.bz2" }

- name: Uncompress Sublime under the tools directory
unarchive: src="{{ cached }}" dest="{{ tools.path }}" creates={{ tools.path }}/sublime_text_3

- name: create SublimeText3 user config folder
file:
path="{{ user.home }}/.config/sublime-text-3/Packages/User/"
state=directory

- name: SublimeText3 configuration
template: src=sublime-text-eclipse-style owner={{ user.name }} group={{ user.name }} dest="{{ user.home }}/.config/sublime-text-3/Packages/User/Default (Linux).sublime-keymap" mode=664

- name: Settings SublimeText Package Control Plugin
template:
src=templates/PackageControl.sublime-settings
dest="{{ user.home }}/.config/sublime-text-3/Packages/User/Package Control.sublime-settings"
tags: fast

- { include: get-and-cache.yml, toget: "http://atom.io/download/rpm" }

- name: Install Atom Text Editor
sudo: yes
dnf: name="{{ cached }}" state=present
tags: atom

- name: create Atom user config folder
file:
path="{{ user.home }}/.atom/"
state=directory

- name: Install Atom Asciidoctor Preview package
shell: apm install asciidoc-preview
changed_when: false

- name: Install Atom Asciidoctor Eclipse Keybindings package
shell: apm install eclipse-keybindings
changed_when: false

###############################################################################################
# VirtualBox
#

# Installing the typical 'kmod-VirtualBox' package through dnf won't work because it has to be
# aligned/republished with the latest kernel and it rarely is.
- name: Configure kernel module for VirtualBox
sudo: yes
shell: 'akmods --kernel $( uname -r )'
changed_when: false
tags: VirtualBox

- name: Configure kernel module for VirtualBox
sudo: yes
shell: systemctl restart systemd-modules-load.service
changed_when: false
tags: VirtualBox
2 changes: 0 additions & 2 deletions templates/atom-apmrc

This file was deleted.

10 changes: 0 additions & 10 deletions templates/dnf.conf

This file was deleted.

28 changes: 0 additions & 28 deletions templates/sublime-text-eclipse-style

This file was deleted.

12 changes: 1 addition & 11 deletions templates/tmuxinator/work.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,4 @@ pre: if [ "$mux_run_resetenv" != "0" ]; then {{ resetenv_path }}/resetenv -t fas

windows:
- home: cd ~
- resetenv: cd {{ resetenv_path }} && git status
# ce if n'est pas pris en compte la 1ère fois sur un `mux start work`
# TODO => trouver un moyen pour que ça fonctionne directement
{% if at_work == true %}
- dev:
layout: main-vertical
panes:
- ssh dev
- ssh dev-bdd
- integ: ssh integ
{% endif %}
- workspace: cd ~/workspace
7 changes: 0 additions & 7 deletions templates/vimrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
syntax on
autocmd Filetype gitcommit setlocal textwidth=72


python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
set laststatus=2
set t_Co=128
20 changes: 0 additions & 20 deletions templates/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ alias t='tmux'
alias tls="tmux ls"
alias ta="tmux a -t"
alias tk="tmux kill-session -t"
# durant changing context (work/home), variables are not correctly set the first time,
# so we must set them before launching tmuxinator
alias twork="r -t fast && mux_run_resetenv=0 mux start work"

source {{ user.home }}/.tmuxinator-completion.zsh

Expand All @@ -70,8 +67,6 @@ alias gwip='git add -A; git ls-files --deleted -z | xargs -r0 git rm; git commit
alias gpr='git pull --rebase'
alias gl='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'

alias lb='mvn clean install -DskipTests -Dinvoker.skip=true'

function httpie_docker() {
docker run -it --rm --net=host clue/httpie $@
}
Expand All @@ -93,23 +88,8 @@ export GOPATH={{ user.home }}/workspace-go
export JAVA_HOME=/usr/lib/jvm/java-1.8.0
export PATH=$JAVA_HOME/bin:$PATH

# JEnv config -- see http://www.jenv.be/
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"

{% if at_work == true %}
export MODE='OpenAirlines'
{% else %}
export MODE='HOME'
{% endif %}

export PS1="[$MODE] $PS1"

unsetproxy() {
unset http_proxy
unset https_proxy
}

source /usr/share/powerline/zsh/powerline.zsh

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
Expand Down

0 comments on commit 5579d34

Please sign in to comment.