Ansible Notes

From Federal Burro of Information
Revision as of 21:25, 5 December 2019 by David (talk | contribs)
Jump to navigationJump to search

output to one line:

 cat /tmp/david/report.java  | perl -n -e " $/ = '' ; print join ( ',' , split\"\n\" ) . \"\n\"; " | more

or -o :P

riun local

sudo ansible-playbook --connection=local --inventory 127.0.0.1,  playbooks/playbook.yml -v

Git install

under rhel6:

cd ~
mkdir work
yum install gcc python-devel
git clone https://github.com/ansible/ansible.git
git submodule update --init --recursive
make install
mkdir /etc/ansible
vi /etc/ansible/hosts

Cloud-init to make tags facts

    - path: /etc/facter/facts.d/tags.sh
      permissions: 0755
      content: |
        #!/usr/bin/env bash
        instanceId=`curl http://169.254.169.254/latest/meta-data/instance-id 2>/dev/null`
        region=`curl http://169.254.169.254/latest/meta-data/placement/availability-zone 2>/dev/null | sed 's/[a-z]$//g'`
        /usr/bin/aws ec2 describe-tags --filters "Name=resource-id,Values=$instanceId" --region $region | jq '.Tags[] | "ec2_tag_" + .Key + "=" + .Value' | tr [:upper:] [:lower:] | tr -d '"'
        exit 0

Also See