Ansible Notes: Difference between revisions
From Federal Burro of Information
Jump to navigationJump to search
(Created page with "output to one line: cat /tmp/david/report.java | perl -n -e " $/ = '' ; print join ( ',' , split\"\n\" ) . \"\n\"; " | more") |
No edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
output to one line: | output to one line: | ||
<pre> | |||
cat /tmp/david/report.java | perl -n -e " $/ = '' ; print join ( ',' , split\"\n\" ) . \"\n\"; " | more | cat /tmp/david/report.java | perl -n -e " $/ = '' ; print join ( ',' , split\"\n\" ) . \"\n\"; " | more | ||
</pre> | |||
or -o :P | |||
== Run 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 AWS tags into facts == | |||
<pre> | |||
- 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 | |||
</pre> | |||
==Also See == | |||
* [[Puppet Notes]] | |||
* http://codeheaven.io/15-things-you-should-know-about-ansible/ |
Latest revision as of 21:56, 9 September 2022
output to one line:
cat /tmp/david/report.java | perl -n -e " $/ = '' ; print join ( ',' , split\"\n\" ) . \"\n\"; " | more
or -o :P
Run 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 AWS tags into 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