Skip to content

Instantly share code, notes, and snippets.

View jriguera's full-sized avatar

José Riguera Lopez jriguera

View GitHub Profile
@jriguera
jriguera / pretty_wget_download.sh
Created June 7, 2015 12:22
Pretty download wrapper for wget
#!/usr/bin/env bash
download() {
local url="$1"
local destin="$2"
echo -n " "
if [ ! -z "${destin}" ]; then
wget --progress=dot "${url}" -O "${destin}" 2>&1 | grep --line-buffered "%" | \
sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
@jriguera
jriguera / nova_scheduler_options.txt
Created June 10, 2015 08:35
Openstack nova Scheduler
# To control the way the scheduler select the host where running a vm:
# Default value is 1.0, negative means that will pack vms on one host
ram_weight_multiplier = -1.0
@jriguera
jriguera / delete_nova.sh
Last active August 29, 2015 14:23
Delete nova compute node
root@node-11:~# nova hypervisor-list
+----+--------------------------+
| ID | Hypervisor hostname |
+----+--------------------------+
| 3 | node-8 |
| 6 | node-12 |
| 9 | node-15 |
+----+--------------------------+
@jriguera
jriguera / deploy_role.txt
Created July 14, 2015 19:20
How to deploy a single role without create a specific playbook
Create a playbook called deploy_role.yml:
- hosts: {{ hosts }}
roles: {{ roles }}
And then you can do:
ansible-playbook deploy_role.yml -e hosts=somehost -e roles=somerole
@jriguera
jriguera / strace.txt
Last active August 29, 2015 14:26
strace examples
# Examples
# Debug syscalls for a daemon
strace -e poll,select,connect,recvfrom,sendto nc www.news.com 80
# Attach to process and sent to output.txt
strace -c -p 11084 -o output.txt
# Check permissions
strace -e open,read,access ls 2>&1 | grep your-filename
@jriguera
jriguera / opensource.txt
Created August 23, 2015 23:07
Howto opensource a project ... or howto keep your configuration not public
GITHUB_URL = Public repo on GitHub.
BITBUCKET_URL = Private repo on Bitbucket.
Given a upstream repo on GitHub in order to clone it to Bitbucket to keep
the configuration non public (for example, to create specific ansible playbooks
with a set of roles), do this (only once!).
1. Create a new repo on Bitbucket. (BITBUCKET_URL)
2. Clone the upstream repo from Github to your local machine: git clone GITHUB_URL
3. git remote rename origin upstream BITBUCKET_URL
@jriguera
jriguera / ksm.sh
Created November 14, 2015 16:14
KSM
#!/usr/bin/env bash
cat <<EOF
http://www.kernel.org/doc/Documentation/vm/ksm.txt :
The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/:
pages_shared - how many shared pages are being used
pages_sharing - how many more sites are sharing them i.e. how much saved
pages_unshared - how many pages unique but repeatedly checked for merging
pages_volatile - how many pages changing too fast to be placed in a tree
@jriguera
jriguera / new_tenant.sh
Created November 17, 2015 15:23
Openstack CLI commands to create a new Project/Tenant and networks using identity V3 (with groups)
# Now we are managing the users on a project by using groups. So everything
# is about creating users and add they to the groups.
# A special user is created always with the same name of the project,
# just to reserve the name and avoid confusion and have an email.
############## Define those variables for the tenant (this is just an example)
TENANT=test
PASSWORD=test
TENANT_DESC="Test"
@jriguera
jriguera / external_net.sh
Created November 17, 2015 16:02
Defining external networks on OpenStack
# Load the admin credentials
. /root/openrc
# Creating the external network type VLAN with VLAND ID == 300 (Online_dev).
# The name of the provider physical_network "ext" is mapped to a physical
# device on the ML2 configuration file of each network node
neutron net-create \
--provider:network_type vlan \
--provider:physical_network ext \
--router:external \
@jriguera
jriguera / bosh_release.md
Last active March 8, 2016 12:29
Creating bosh releases

Start here: http://mariash.github.io/learn-bosh/, then goto: http://bosh.io/docs/create-release.html

  1. Prepare the environment with bosh lite.
  2. Create the workspace for the new release: bosh init release <release_name>
  3. Create the source packages to compile: bosh generate package <package_name>
  4. After defining the compilation steps, add the source packages bosh add blob <package.tgz> <package_name>
  5. Create the job (or jobs) to run: bosh generate job <job_name> and write the monit, spec and startup files
  6. Create a manifest for the new project: http://bosh.io/docs/deployment-manifest.html, using cd templates && make_manifest warden. Option: copy from another simple release like: https://github.com/cloudfoundry-community/carbon-c-relay-boshrelease
  7. bosh status has to be pointing to the deployment manifest created before.