Skip to content

Instantly share code, notes, and snippets.

@napcs
Created June 22, 2018 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save napcs/316b2533b4b566854a9d1ed72b001b2a to your computer and use it in GitHub Desktop.
Save napcs/316b2533b4b566854a9d1ed72b001b2a to your computer and use it in GitHub Desktop.
playbook for dev server
---
- hosts: all
remote_user: root
tasks:
- name: Add "sammy" non-root sudo user
user:
name: sammy
# THIS IS BAD - DON'T PUT PASSWORDS IN PRODUCTION FILES -
# I CAN DO THIS BECAUSE THIS IS A PRIVATE TESTING SERVER.
# Instead, generate password externally with
# pip install
# python -c "from passlib.hash import sha512_crypt; import getpass; print sha512_crypt.using(rounds=5000).hash(getpass.getpass())"
# and put the hash in the file here.
password: "{{ 'sammy' | password_hash('sha512') }}"
shell: /bin/bash
update_password: on_create
groups: sudo
append: true
- name: Add public key for "sammy"
authorized_key:
user: sammy
state: present
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
- name: "Add sudo alias to bashrc for sammy"
lineinfile:
path: /home/sammy/.bashrc
line: 'alias sudo="sudo "'
- name: "Add nano to vim alias for sammy"
lineinfile:
path: /home/sammy/.bashrc
line: 'alias nano="vim"'
- name: Install additional software (vim, tree, direnv, ranger, build-essential)
apt:
name:
- vim
- tree
- direnv
- ranger
- build-essential
state: present
update_cache: yes
- name: "download dotfiles"
git:
repo: https://github.com/napcs/dotfiles.git
# TODO: set fact for the foldername.
dest: /home/sammy/dotfiles
update: yes
- name: Ensure apt version of tmux is not installed.
apt:
name: tmux
state: absent
- name: Ensure dependencies are installed.
apt:
name:
- libevent-dev
- libncurses5-dev
- build-essential
- automake
- pkg-config
- git
- name: Download tmux source.
get_url:
url: "https://github.com/tmux/tmux/releases/download/2.7/tmux-2.7.tar.gz"
dest: "/tmp/tmux.tar.gz"
- name: Extract tmux archive
unarchive:
src: "/tmp/tmux.tar.gz"
dest: /tmp/tmux
creates: "/tmp/tmux/configure"
copy: false
- name: Install Tmux.
shell: cd /tmp/tmux && ./configure && make && make install
args:
creates: /usr/bin/tmux
- name: "Symlink dotfiles"
file:
src: /home/sammy/dotfiles/{{ item.source }}
dest: /home/sammy/{{ item.dest }}
state: link
with_items:
- { source: '.vimrc', dest: '.vimrc' }
- { source: '.vim', dest: '.vim' }
- { source: '.tmux.conf', dest: '.tmux.conf' }
- { source: '.config', dest: '.config' }
- { source: '.git_completion.bash', dest: '.git_completion.bash' }
- { source: '.gemrc', dest: '.gemrc' }
- { source: '.irbrc', dest: '.irbrc' }
- { source: '.bash_profile', dest: '.bash_profile' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment