Added idempotency to developer tasks

This commit is contained in:
2017-10-09 08:12:28 -04:00
parent 4f1d604089
commit 3d94a3b5b6
4 changed files with 51 additions and 63 deletions

View File

@@ -6,3 +6,4 @@ docker_ce_version_to_install: 17.06.0~ce-0~ubuntu
registry_location: registry.wimer.local:5000 registry_location: registry.wimer.local:5000
nfs_location: 10.0.0.150 nfs_location: 10.0.0.150
home_pub_key: https://raw.githubusercontent.com/jcwimer/ubuntu-template/master/post/id_rsa.pub home_pub_key: https://raw.githubusercontent.com/jcwimer/ubuntu-template/master/post/id_rsa.pub
standard_user: cody

View File

@@ -42,24 +42,30 @@
- linux-headers-server - linux-headers-server
- tmux - tmux
- name: Add standard_user to docker group
user:
name: {{ standard_user }}
groups: docker
append: yes
- name: Set authorized key took from url - name: Set authorized key took from url
become: yes become: yes
become_user: cody become_user: {{ standard_user }}
authorized_key: authorized_key:
user: cody user: {{ standard_user }}
state: present state: present
key: {{ home_pub_key }} key: {{ home_pub_key }}
- git_config: - git_config:
become: yes become: yes
become_user: cody become_user: {{ standard_user }}
name: user.name name: user.name
scope: local scope: local
value: 'Jacob Cody Wimer' value: 'Jacob {{ standard_user }} Wimer'
- git_config: - git_config:
become: yes become: yes
become_user: cody become_user: {{ standard_user }}
name: user.email name: user.email
scope: local scope: local
value: 'jacob.wimer@gmail.com' value: 'jacob.wimer@gmail.com'
@@ -84,14 +90,7 @@
name: America/New_York name: America/New_York
- name: Replace sudoers file - name: Replace sudoers file
template: src=../roles/common/templates/sudoers.j2 dest=/etc/sudoers template: src=../roles/common/templates/sudoers.j2 dest=/etc/sudoers
- name: Replace fstab file
lineinfile: dest=/etc/fstab
regexp="^{{ nfs_location }}"
state=present
line="{{ nfs_location }}:/volumeUSB1/usbshare/raw-files/fileserver/shares/lab-data /data nfs defaults 0 0"
- name: Replace docker daemon file - name: Replace docker daemon file
template: src=../roles/common/templates/docker-daemon.json.j2 dest=/etc/docker/daemon.json template: src=../roles/common/templates/docker-daemon.json.j2 dest=/etc/docker/daemon.json
@@ -104,7 +103,13 @@
- name: Creates directory - name: Creates directory
file: path=/data state=directory file: path=/data state=directory
- name: Mount data directory - name: USB lab data in fstab
lineinfile: dest=/etc/fstab
regexp="^{{ nfs_location }}:/volumeUSB1"
state=present
line="{{ nfs_location }}:/volumeUSB1/usbshare/raw-files/fileserver/shares/lab-data /data nfs defaults 0 0"
- name: Mount USB lab data directory
mount: mount:
path: /data path: /data
src: 10.0.0.150:/volumeUSB1/usbshare/raw-files/fileserver/shares/lab-data src: 10.0.0.150:/volumeUSB1/usbshare/raw-files/fileserver/shares/lab-data

View File

@@ -2,20 +2,20 @@
# This playbook contains plays that will run on developer-machines # This playbook contains plays that will run on developer-machines
- name: Is rvm installed - name: Is rvm installed
stat: path=/home/cody/.rvm stat: path=/home/{{ standard_user }}/.rvm
register: rvm_installed register: rvm_installed
- name: Install rvm key - name: Install rvm key
shell: gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 shell: gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
when: not rvm_installed.stat.exists when: not rvm_installed.stat.exists
become: true become: true
become_user: cody become_user: {{ standard_user }}
- name: Install rvm and latest ruby - name: Install rvm and latest ruby
shell: \curl -sSL https://get.rvm.io | bash -s stable shell: \curl -sSL https://get.rvm.io | bash -s stable
when: not rvm_installed.stat.exists when: not rvm_installed.stat.exists
become: true become: true
become_user: cody become_user: {{ standard_user }}
- name: Is heroku installed - name: Is heroku installed
shell: which heroku shell: which heroku
@@ -37,62 +37,56 @@
- name: Install other apt items - name: Install other apt items
apt: name={{ item }} state=present apt: name={{ item }} state=present
with_items: with_items:
- siege
- vim
- tmux
- apache2-utils
- xrdp - xrdp
- ack-grep
- tmate - tmate
- nodejs - nodejs
- npm - npm
- name: Install localtunnel - name: Install localtunnel
shell: npm install -g localtunnel npm:
name: localtunnel
- name: Pathogen installed global: yes
stat: path=/home/cody/.vim/autoload/pathogen.vim
register: pathogen_installed
- name: Create vim autoload directory - name: Create vim autoload directory
file: path=/home/cody/.vim/autoload state=directory file: path=/home/{{ standard_user }}/.vim/autoload state=directory
become: yes become: yes
become_user: cody become_user: {{ standard_user }}
- name: Create vim bundle directory - name: Create vim bundle directory
file: path=/home/cody/.vim/bundle state=directory file: path=/home/{{ standard_user }}/.vim/bundle state=directory
become: yes become: yes
become_user: cody become_user: {{ standard_user }}
- name: Install pathogen - name: Install pathogen
shell: curl -LSso /home/cody/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
when: not pathogen_installed.stat.exists
become: yes become: yes
become_user: cody become_user: {{ standard_user }}
git: repo=https://github.com/tpope/vim-pathogen.git
- name: Replace .vimrc dest=/home/{{ standard_user }}/.vim/autoload/pathogen.vim
template: src=../roles/developer-machine/templates/vimrc.j2 dest=/home/cody/.vimrc
become: yes
become_user: cody
- name: Nerdtree installed
stat: path=/home/cody/.vim/bundle/nerdtree
register: nerdtree_installed
- name: Install nerdtree - name: Install nerdtree
git: repo=https://github.com/scrooloose/nerdtree.git git: repo=https://github.com/scrooloose/nerdtree.git
dest=/home/cody/.vim/bundle/nerdtree dest=/home/{{ standard_user }}/.vim/bundle/nerdtree
when: not nerdtree_installed.stat.exists
become: yes become: yes
become_user: cody become_user: {{ standard_user }}
- name: Replace fstab file - name: Replace .vimrc
template: src=../roles/developer-machine/templates/fstab.j2 dest=/etc/fstab template: src=../roles/developer-machine/templates/vimrc.j2 dest=/home/{{ standard_user }}/.vimrc
become: yes
become_user: {{ standard_user }}
- name: Creates directory - name: Creates directory
file: path=/data state=directory file: path=/data state=directory
- name: Mount data directory - name: USB raw files in fstab
shell: mount 10.0.0.150:/volumeUSB1/usbshare/raw-files /data lineinfile: dest=/etc/fstab
ignore_errors: yes regexp="^{{ nfs_location }}:/volumeUSB1"
state=present
line="{{ nfs_location }}:/volumeUSB1/usbshare/raw-files /data nfs defaults 0 0"
- name: Mount USB raw files to data directory
mount:
path: /data
src: 10.0.0.150:/volumeUSB1/usbshare/raw-files
state: present

View File

@@ -1,12 +0,0 @@
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=a4a5a54f-1022-47b3-9c50-77c6139d7fc9 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=0f47da63-9d7d-487c-8b99-ea7d5497f7f7 none swap sw 0 0
10.0.0.150:/volumeUSB1/usbshare/raw-files /data nfs defaults 0 0