Skip to content

Instantly share code, notes, and snippets.

View phips's full-sized avatar
🇬🇧

Mark Phillips phips

🇬🇧
View GitHub Profile
Vagrant.configure("2") do |config|
config.vm.box = "base"
# strat with Vagrant configuration v2 need specify VM provider
config.vm.provider :virtualbox do |vb|
file_to_disk = '/tmp/large_disk.vdi'
# disk size 50GB
vb.customize ['createhd', '--filename', file_to_disk, '--size', 50 * 1024]
vb.customize ['storageattach', :id, '--storagectl', 'SATA', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
end
@phips
phips / vbox_cmnds.sh
Created August 20, 2013 19:34
Add a DVD drive to a VirtualBox VM from the shell
VboxManage storagectl VMNAME --name CD --add ide --controller PIIX4
VboxManage storageattach VMNAME --storagectl CD --type dvddrive --port 0 --device 0 --medium emptydrive
@phips
phips / cpanm.yaml
Last active February 13, 2016 21:49
Install cpanm on vanilla CentOS 6 Vagrant box with Ansible
---
- hosts: default
user: vagrant
gather_facts: false
sudo: true
tasks:
- name: Ensure gcc installed
yum: name=gcc state=present
@phips
phips / gist:8388109
Created January 12, 2014 17:56
Allow logwatch to write to an NFS mounted directory
module logwatch_nfs_write 1.0;
require {
type logwatch_t;
type nfs_t;
class dir write;
}
#============= logwatch_t ==============
#!!!! The source type 'logwatch_t' can write to a 'dir' of the following types:
@phips
phips / kibana.yaml
Last active August 29, 2015 13:56
Install Kibana into Vagrant box
---
- hosts: default
gather_facts: false
sudo: true
vars:
kibana: https://download.elasticsearch.org/kibana/kibana/kibana-3.1.0.tar.gz
kbver: 3.1.0
es: https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.noarch.rpm
ls: https://download.elasticsearch.org/logstash/logstash/packages/centos/logstash-1.4.2-1_2c0f5a1.noarch.rpm
tasks:
@phips
phips / play.yaml
Created February 20, 2014 16:57
Ansible: Check command output, react in next task
- name: Red Hat - Check subscription status
shell: /usr/sbin/subscription-manager list
register: subs
when: ansible_distribution == 'RedHat'
- name: Red Hat - Ensure registered to RHN (1/2)
shell: /usr/sbin/subscription-manager register --username USER --password PASS
when: ansible_distribution == 'RedHat' and "Subscribed" not in subs.stdout
@phips
phips / site.yml
Created March 13, 2014 15:30
Ansible dynamic grouping
---
- hosts: all
tasks:
- group_by: key={{ ansible_virtualization_type }}
# Include *all* groups here
- include: webservers.yml
##
@phips
phips / Makefile
Created April 16, 2014 21:01
ansible control Makefile
.PHONY: run test
# default inventory file
INV ?= dev
# default play
PLAY ?= site
# If a variable file is encrypted with Vault, create a file with the password
# in and run the make with SWITCHES including '--vault-password-file FILE'.
# Naturally DO NOT put that file in Git!
@phips
phips / Vagrantfile
Last active February 10, 2016 08:02 — forked from jtopper/gist:8588263
host1.vm.provider :vmware_fusion do |vmw|
vdiskmanager = '/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager'
dir = "#{ENV['PWD']}/.vagrant/additional-disks"
unless File.directory?( dir )
Dir.mkdir dir
end
file_to_disk = "#{dir}/hd2.vmdk"
unless File.exists?( file_to_disk )
`#{vdiskmanager} -c -s 10GB -a lsilogic -t 0 #{file_to_disk}`
end
@phips
phips / hosts.yml
Last active August 2, 2021 19:59
Ansible setting of hostname from inventory, but ignoring IP addresses
- name: Ensure hostname set
hostname:
name: {{ inventory_hostname }}
when: not inventory_hostname|trim is match('(\d{1,3}\.){3}\d{1,3}')
- name: Ensure hostname is in /etc/hosts
lineinfile:
dest: /etc/hosts
regexp: "^{{ ansible_default_ipv4.address }}.+$"
line: "{{ ansible_default_ipv4.address }} {{ ansible_fqdn }} {{ ansible_hostname }}"