View setup_ansible_virtualenvs.sh
#!/usr/bin/env bash
set -x
ANSIBLE_VERSIONS=("1.9.4" "1.9.5" "1.9.6" "2.0.0.0" "2.0.0.1" "2.0.0.2" \
"2.0.1.0" "2.0.2.0" "2.1.0.0" "2.1.1.0" "2.1.2.0" \
"2.1.3.0" "2.1.4.0" "2.2.0.0" "2.2.1.0" "2.2.2.0" "2.2.3.0" \
"2.3.0.0")
VIRTUALENV_PATH="./python-virtualenvs"
pip install virtualenv
View dig2JSON
foo=$(dig google.com +nocomments +noquestion +noauthority +noadditional +nostats | awk '{if (NR>3){print}}'| jq -R 'split("\t") |{Name:.[0],TTL:.[2],Class:.[3],Type:.[4],IpAddress:.[5]}' | jq --slurp .) | jq -n --argjson v $foo '{"foo": $v}'
View email_notifications.txt.j2
The following machines were included in this execution:
# Defined machines marked as broken
{% if groups['maas_broken_machines'] is defined %}
maas_broken_machines:
{% for host in groups['maas_broken_machines'] %}
- '{{ host }}'
{% endfor %}
{% elif groups['maas_broken_machines'] is not defined %}
maas_broken_machines: []
View kvm_vms_list.yml.j2
---
{% if groups['kvm_vms_list'] is defined %}
kvm_vms_list:
{% for item in groups['kvm_vms_list'] %}
- '{{ item }}'
{% endfor %}
{% elif groups['kvm_vms_list'] is not defined %}
kvm_vms_list: []
{% endif %}
View maas.inventory.inv.j2
[maas_non_provisioned]
{% for host in (maas_machines['stdout']|from_json) %}
{% if groups['maas_deployed_machines'] is defined %}
{% if host['fqdn'] not in groups['maas_deployed_machines'] %}
{{ host['fqdn'] }}
{% elif host['hostname'] not in groups['maas_deployed_machines'] %}
{{ host['hostname'] }}
{% endif %}
{% elif groups['maas_deployed_machines'] is not defined %}
{{ host['fqdn'] }}
View maas_management_vars.yml.j2
---
# Defined vars from first maas play to continue onto additional plays.
# these will eventually be put into group_vars
inventory_directory: '{{ inventory_directory }}'
maas_login_profile: '{{ maas_login_profile }}'
maas_login_url: '{{ maas_login_url }}'
maas_login_user: '{{ maas_login_user }}'
maas_match_kvm_name: {{ maas_match_kvm_name }}
maas_virsh_user: '{{ maas_virsh_user }}'
View maas_management.yml
---
- hosts: kvm_hosts
remote_user: remote
become: true
vars:
roles:
tasks:
- name: Capturing VM(s)
virt:
command: "list_vms"
View hosts.csv
inventory_hostname inventory_name ansible_host macaddress
hamlin-brenda.etsbv.internal server000.etsbv.internal 10.14.200.90 02:16:3e:56:a0:f6
sicilian-michael.etsbv.internal server001.etsbv.internal 10.183.84.9 02:16:3e:27:9c:64
oldham-ethel.etsbv.internal server002.etsbv.internal 10.175.134.46 02:16:3e:6b:96:56
maynard-david.etsbv.internal server003.etsbv.internal 10.223.68.138 02:16:3e:31:48:7d
matthews-diane.etsbv.internal server004.etsbv.internal 10.248.19.13 02:16:3e:14:8c:cb
daniels-john.etsbv.internal server005.etsbv.internal 10.216.233.170 02:16:3e:77:a3:0e
compton-robin.etsbv.internal server006.etsbv.internal 10.66.30.71 02:16:3e:3f:68:4a
rodriguez-sara.etsbv.internal server007.etsbv.internal 10.222.250.172 02:16:3e:11:4c:ce
fox-paul.etsbv.internal server008.etsbv.internal 10.234.241.248 02:16:3e:24:1c:8c
View iterate_hosts.yml
---
hostipmacs:
- host: 'hamlin-brenda.etsbv.internal'
inventory_name: 'server000.etsbv.internal'
ip: '10.14.200.90'
mac: '02:16:3e:56:a0:f6'
- host: 'sicilian-michael.etsbv.internal'
inventory_name: 'server001.etsbv.internal'
ip: '10.183.84.9'
mac: '02:16:3e:27:9c:64'
View iterate_csv.j2
---
hostipmacs:
{% for item in csvfile.split("\n") %}
{% if loop.index != 1 %}
{% set list = item.split(",") %}
- host: '{{ list[0]|trim() }}'
inventory_name: '{{ list[1]|trim() }}'
ip: '{{ list[2]|trim() }}'
mac: '{{ list[3]|trim() }}'
{% endif %}