Skip to content

Instantly share code, notes, and snippets.

@polster
polster / Project structure
Created April 20, 2015 15:24
Multiple config profiles with Maven
src/main/resources
|
+- local
| |
| `- specific.properties
+- dev
|
`- specific.properties
@polster
polster / sample.yml
Created April 24, 2015 05:15
How to check via Ansible if binary is installed
- name: Register maven installation status
command: which mvn
changed_when: false
failed_when: false
register: mvn_installed
- name: Check maven installation status
fail:
msg: "Maven appears to be missing, install first"
when: mvn_installed|failed
@polster
polster / sample.yml
Created April 24, 2015 05:20
How to set Ansible fact over condition
- name: "Retrieve user's home path if not set"
sudo: yes
sudo_user: "{{ user }}"
shell: "echo $HOME"
register: _user_homedir
when: user_home == ""
- name: Set home path to be used for configuration
set_fact:
user_homedir: "{{ _user_homedir.stdout if user_home == '' else user_home }}"
@polster
polster / cert-fetch-add-commands.sh
Last active August 29, 2015 14:20
How to download untrusted cert and add to JVM keystore
# Download cert
openssl s_client -connect [host or IP]:[port] < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > public.crt
# Import into the default JVM trust store
$JAVA_HOME/bin/keytool -import -alias devops-repo -keystore $JAVA_HOME/lib/security/cacerts -file public.crt -storepass changeit
@polster
polster / bower.json
Created May 7, 2015 22:48
How to declare local bower dependency
{
"name": "myproject",
"version": "1.0.0",
"dependencies": {
"jquery": "1.8.0",
"twitter/bootstrap": "2.1.1",
"mypackage": "file:///path/to/mypackage/.git#master"
}
}
@polster
polster / main.yml
Created May 11, 2015 21:12
How to install yum pacakge list
- name: Make sure package dependencies are installed
yum:
name: "{{ item.package }}"
state: present
with_items: my_role_os_package_list
when: my_role_os_package_list|length > 0
@polster
polster / main.yml
Created May 12, 2015 21:37
How to manage sudoers with Ansible
name: Create sudoers.d directory
file:
path: /etc/sudoers.d
owner: root
group: root
mode: 0755
state: directory
- name: Set includedir in sudoers
lineinfile:
@polster
polster / yosemite-bluetooth-fix.sh
Created June 4, 2015 05:09
OSX Yosemite Bluetooth Sleep Fix
#!/bin/bash
#
# Install an configure sleepwatcher via brew for the current user
# Install
brew install sleepwatcher
# Configure
sudo tee -a /etc/rc.wakeup <<EOF
kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@polster
polster / download-cert.sh
Created June 14, 2015 20:12
How to download cert via terminal
echo -n | openssl s_client -connect HOST:PORTNUMBER | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/$SERVERNAME.cert
@polster
polster / main.yml
Last active August 29, 2015 14:23
How to process multiple files in Ansible
- name: Copy trusted repo gpg keys
copy:
src: "{{ item }}"
dest: "/etc/pki/rpm-gpg"
with_fileglob:
- RedHat/RPM-GPG-KEY-*-{{ os_version_major }}