Made common task idempotent
This commit is contained in:
@@ -3,3 +3,6 @@
|
|||||||
|
|
||||||
docker_compose_version_to_install: 1.14.0
|
docker_compose_version_to_install: 1.14.0
|
||||||
docker_ce_version_to_install: 17.06.0~ce-0~ubuntu
|
docker_ce_version_to_install: 17.06.0~ce-0~ubuntu
|
||||||
|
registry_location: registry.wimer.local:5000
|
||||||
|
nfs_location: 10.0.0.150
|
||||||
|
home_pub_key: https://raw.githubusercontent.com/jcwimer/ubuntu-template/master/post/id_rsa.pub
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
# This playbook contains plays that will run on all nodes
|
# This playbook contains plays that will run on all nodes
|
||||||
|
|
||||||
- name: Get docker key
|
- name: Get docker key
|
||||||
shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
|
apt-key:
|
||||||
|
url: https://download.docker.com/linux/ubuntu/gpg
|
||||||
|
state: present
|
||||||
|
# shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
|
||||||
|
|
||||||
- name: Add docker repo
|
- name: Add docker repo
|
||||||
apt_repository:
|
apt_repository:
|
||||||
@@ -32,16 +35,34 @@
|
|||||||
- nfs-common
|
- nfs-common
|
||||||
- docker-ce={{docker_ce_version_to_install}}
|
- docker-ce={{docker_ce_version_to_install}}
|
||||||
- sshpass
|
- sshpass
|
||||||
|
- ack-grep
|
||||||
|
- dnsutils
|
||||||
|
- nmon
|
||||||
|
- build-essential
|
||||||
|
- linux-headers-server
|
||||||
|
- tmux
|
||||||
|
|
||||||
- name: Set git username
|
- name: Set authorized key took from url
|
||||||
become: yes
|
become: yes
|
||||||
become_user: cody
|
become_user: cody
|
||||||
shell: git config --global user.name "Jacob Cody Wimer"
|
authorized_key:
|
||||||
|
user: cody
|
||||||
|
state: present
|
||||||
|
key: {{ home_pub_key }}
|
||||||
|
|
||||||
- name: Set git email
|
- git_config:
|
||||||
become: yes
|
become: yes
|
||||||
become_user: cody
|
become_user: cody
|
||||||
shell: git config --global user.email "jacob.wimer@gmail.com"
|
name: user.name
|
||||||
|
scope: local
|
||||||
|
value: 'Jacob Cody Wimer'
|
||||||
|
|
||||||
|
- git_config:
|
||||||
|
become: yes
|
||||||
|
become_user: cody
|
||||||
|
name: user.email
|
||||||
|
scope: local
|
||||||
|
value: 'jacob.wimer@gmail.com'
|
||||||
|
|
||||||
- name: Docker compose version
|
- name: Docker compose version
|
||||||
shell: docker-compose --version
|
shell: docker-compose --version
|
||||||
@@ -59,26 +80,35 @@
|
|||||||
docker_compose_version.stdout != "docker-compose version: {{docker_compose_version_to_install}}"
|
docker_compose_version.stdout != "docker-compose version: {{docker_compose_version_to_install}}"
|
||||||
|
|
||||||
- name: Set timezone to NewYork
|
- name: Set timezone to NewYork
|
||||||
shell: timedatectl set-timezone America/New_York
|
timezone:
|
||||||
|
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
|
- name: Replace fstab file
|
||||||
template: src=../roles/common/templates/fstab.j2 dest=/etc/fstab
|
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
|
||||||
|
register: docker-daemon
|
||||||
|
|
||||||
- name: Restart docker service
|
- name: Restart docker service
|
||||||
shell: service docker restart
|
shell: service docker restart
|
||||||
|
when: docker-daemon.changed
|
||||||
|
|
||||||
- name: Creates directory
|
- name: Creates directory
|
||||||
file: path=/data state=directory
|
file: path=/data state=directory
|
||||||
|
|
||||||
- name: Mount data directory
|
- name: Mount data directory
|
||||||
shell: mount 10.0.0.150:/volumeUSB1/usbshare/raw-files/fileserver/shares/lab-data /data
|
mount:
|
||||||
ignore_errors: yes
|
path: /data
|
||||||
|
src: 10.0.0.150:/volumeUSB1/usbshare/raw-files/fileserver/shares/lab-data
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: test for swap partition
|
- name: test for swap partition
|
||||||
shell: swapon -s | grep -E "^/"
|
shell: swapon -s | grep -E "^/"
|
||||||
@@ -131,4 +161,4 @@
|
|||||||
lineinfile: dest=/etc/sysctl.conf
|
lineinfile: dest=/etc/sysctl.conf
|
||||||
regexp="^vm.vfs_cache_pressure"
|
regexp="^vm.vfs_cache_pressure"
|
||||||
state=present
|
state=present
|
||||||
line="vm.swappiness = 50"
|
line="vm.vfs_cache_pressure = 50"
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"insecure-registries" : ["registry:5000"]
|
"insecure-registries" : ["{{ regitstry_location }}"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/fileserver/shares/lab-data /data nfs defaults 0 0
|
|
||||||
Reference in New Issue
Block a user