<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ansible on iMil.net</title>
    <link>http://imil.net/blog/tags/ansible/</link>
    <description>Recent content in Ansible on iMil.net</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 29 Oct 2022 22:41:26 +0200</lastBuildDate>
    <atom:link href="http://imil.net/blog/tags/ansible/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Generate An Ansible Report By Updating A Variable</title>
      <link>http://imil.net/blog/posts/2022/generate-ansible-report/</link>
      <pubDate>Sat, 29 Oct 2022 22:41:26 +0200</pubDate>
      <guid>http://imil.net/blog/posts/2022/generate-ansible-report/</guid>
      <description>&lt;p&gt;At &lt;em&gt;$(DAYJOB)&lt;/em&gt; I was asked to generate some kind of daily report, and I thought &lt;em&gt;ansible&lt;/em&gt; would do the job; we basically want to have a couple of key metrics like &lt;em&gt;load average, memory, disk&lt;/em&gt;… you see the deal. The result is to be send to &lt;em&gt;MatterMost&lt;/em&gt; using &lt;a href=&#34;https://docs.ansible.com/ansible/latest/collections/community/general/mattermost_module.html&#34;&gt;mattermost&amp;rsquo;s ansible module&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It took me way too much time to understand how to update a single variable in order to build a &lt;em&gt;mardown&lt;/em&gt; table that would be sent as a single request to the &lt;em&gt;MatterMost&lt;/em&gt; server, until &lt;a href=&#34;https://twitter.com/neith_speed&#34;&gt;neith_speed&lt;/a&gt; told me to use &lt;code&gt;hostvars&lt;/code&gt; in order to have access to the data gathered by the play for every host.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Ansible playbook with packer in Jenkins</title>
      <link>http://imil.net/blog/posts/2017/ansible-playbook-with-packer-in-jenkins/</link>
      <pubDate>Sat, 25 Mar 2017 12:23:18 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2017/ansible-playbook-with-packer-in-jenkins/</guid>
      <description>&lt;p&gt;Quick one.&lt;/p&gt;&#xA;&lt;p&gt;While working on a build chain in order to register home-baked &lt;em&gt;AMIs&lt;/em&gt;, I wanted to use the &lt;code&gt;ansible-local&lt;/code&gt; &lt;a href=&#34;https://www.packer.io/&#34;&gt;packer&lt;/a&gt; &lt;em&gt;provisioner&lt;/em&gt; to setup the instance with a very basic &lt;em&gt;playbook&lt;/em&gt;. I needed to provide &lt;code&gt;ansible&lt;/code&gt; a playbook but didn&amp;rsquo;t find immediately how to achieve this within the &lt;a href=&#34;https://wiki.jenkins-ci.org/display/JENKINS/Packer+Plugin&#34;&gt;Jenkins-packer&lt;/a&gt; module. Turns out it&amp;rsquo;s tricky, in the &lt;em&gt;JSON Template Text&lt;/em&gt; (or the template file), declare the &lt;code&gt;playbook_file&lt;/code&gt; like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;type&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ansible-local&amp;#34;&lt;/span&gt;,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;playbook_file&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;{{ user `test_yml` }}&amp;#34;&lt;/span&gt;,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;command&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;PYTHONUNBUFFERED=1 ansible-playbook&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then in the &lt;em&gt;File Entries&lt;/em&gt; field, the &lt;em&gt;Variable Name&lt;/em&gt; must be &lt;code&gt;test_yml&lt;/code&gt; and &lt;em&gt;File Contents&lt;/em&gt; filled with the playbook.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Ansible and AWS ASG, a (really) dynamic inventory</title>
      <link>http://imil.net/blog/posts/2016/ansible_and_aws_asg/</link>
      <pubDate>Fri, 05 Aug 2016 14:07:00 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2016/ansible_and_aws_asg/</guid>
      <description>&lt;p&gt;I found myself searching ridiculously too long to achieve what I believed was a simple task: to apply an &lt;a href=&#34;http://www.ansible.com&#34;&gt;Ansible&lt;/a&gt; &lt;em&gt;role&lt;/em&gt; to newly created  instances&amp;hellip; started by an &lt;a href=&#34;https://aws.amazon.com/autoscaling/&#34;&gt;Auto Scaling Group&lt;/a&gt;. If you&amp;rsquo;re used to &lt;a href=&#34;http://www.ansible.com&#34;&gt;Ansible&lt;/a&gt; you know that it relies on an &lt;em&gt;inventory&lt;/em&gt; to apply a &lt;code&gt;playbook&lt;/code&gt;, but obviously, when you&amp;rsquo;re firing up &lt;em&gt;EC2&lt;/em&gt; instances with the same &lt;code&gt;playbook&lt;/code&gt;, you are not able to know what will be your virtual machines IP addresses, nor can &lt;a href=&#34;http://docs.ansible.com/ansible/intro_dynamic_inventory.html&#34;&gt;ec2.py&lt;/a&gt;, the recommended method to deal with dynamic inventories.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
