Andrew Latham

I was playing around and just wrote:

- name: Kill banned services
  shell: "pkill -f {{ item }}"
  with_items: "{{ banned_services }}"
  ignore_errors: yes
  changed_when: False
  failed_when: False

Which will run pkill against a list of names which is both dangerous and effective at the same time. This will look like:

TASK [common : Kill banned services] **********************************
ok: [192.168.15.12] => (item=screen)
ok: [192.168.15.13] => (item=screen)
ok: [192.168.15.11] => (item=screen)
ok: [192.168.15.12] => (item=tmux)
ok: [192.168.15.11] => (item=tmux)
ok: [192.168.15.13] => (item=tmux)

Which should be all green and evil at the same time.

Andrew Latham

Playing with some libvirt stuffs and setup a quick task to get my HVM nodes working the way I want. Will update with some fine tuning over time.

---

- name: HVM Packages to install 
  apt: 
    name: "{{ item }}"
    state: latest
  with_items:
    - qemu-kvm
    - libvirt-clients 
    - libvirt-daemon-system

- name: Add user to group
  user:
    name: hvm
    groups: libvirt-qemu,libvirt
    append: yes
Andrew Latham

Easy start with Ansible

Example from a local ansible source tree without using any install to run adhoc commands

Setup

Download or checkout the software, unpack and change into the base directory. We will then run a script to setup the environment. This can and should be done as a user and not root. Note you may need to install packages like python3-paramiko, python-paramiko, python3-jinja2, python-jinja2, python3-yaml, python-yaml and others to use Ansible.

cat hacking/README.md
source hacking/env-setup

Assume key works

./bin/ansible all -i 192.168.15.11, -a "uname -a"
192.168.15.11 | SUCCESS | rc=0 >>
Linux nodeone 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux

Set key

 ./bin/ansible all -i 192.168.15.11, -a "uname -a" --private-key=~/.ssh/id_rsa
192.168.15.11 | SUCCESS | rc=0 >>
Linux nodeone 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux

whoami

./bin/ansible all -i 192.168.15.11, -a "whoami" --private-key=~/.ssh/id_rsa
192.168.15.11 | SUCCESS | rc=0 >>
lathama

become root via su

./bin/ansible all -i 192.168.15.11, --private-key=~/.ssh/id_rsa -b --become-method=su -K -a "whoami"
SU password: 
192.168.15.11 | SUCCESS | rc=0 >>
root