title: Amazon Linux machine - Ansible ansible_distribution* variables major release distribution
body: <p>I'm using <strong>Ansible: 2.2.0.0</strong></p>
  
  <h2>I have 3 machines:</h2>
  
  <p>Two vagrant boxes (one CentOS 7.x and one Ubuntu 14.04) and <br>
  3rd box is an EC2 Amazon Linux instance (Amazon Linux AMI release
      2016.03).</p>
  
  <p>On these boxes, I'm <strong>running the following command</strong> and getting valid output (as listed below): </p>
  
  <p><strong>CentOS</strong>:</p>
  
  <pre><code>[vagrant@myvagrant ~] $ ansible all -m setup -i "`hostname`," --connection=local -a "filter=ansible_distribution*"
  myvagrant | SUCCESS =&gt; {
      "ansible_facts": {
          "ansible_distribution": "CentOS", 
          "ansible_distribution_major_version": "7", 
          "ansible_distribution_release": "Core", 
          "ansible_distribution_version": "7.2.1511"
      }, 
      "changed": false
  }
  </code></pre>
  
  <p><strong>Ubuntu</strong>:</p>
  
  <pre><code>vagrant@myubuntuvagrant:~$ ansible all -m setup -i "`hostname`," --connection=local -a "filter=ansible_distribution*"
  myubuntuvagrant | SUCCESS =&gt; {
      "ansible_facts": {
          "ansible_distribution": "Ubuntu", 
          "ansible_distribution_major_version": "14", 
          "ansible_distribution_release": "trusty", 
          "ansible_distribution_version": "14.04"
      }, 
      "changed": false
  }
  vagrant@myubuntuvagrant:~$ 
  </code></pre>
  
  <p><strong>Amazon EC2 instance/box</strong>:</p>
  
  <pre><code>$ ansible all -m setup -i "`hostname`," --connection=local -a "filter=ansible_distribution*"
  ip-10-200-1-145 | SUCCESS =&gt; {
      "ansible_facts": {
          "ansible_distribution": "Amazon", 
          "ansible_distribution_major_version": "NA", 
          "ansible_distribution_release": "NA", 
          "ansible_distribution_version": "2016.03"
      }, 
      "changed": false
  }
  </code></pre>
  
  <p>In one of my Ansible playbook / templates/yum.repos.d.file.j2 file, I'm using <code>{{ ansible_distribution_major_version }}</code> variable and using it's value in a .repo file for the <code>baseurl</code> property's value for CentOS/Amazon EC2 instance <strong>only</strong> i.e. <code>when: ansible_distribution == "CentOS" or ansible_distribution == "Amazon"</code>. </p>
  
  <p><code>baseurl=https://packagecloud.io/company/packages/telegraf/el/6/$basearch</code></p>
  
  <p><strong>PS:</strong> I'm not looking for Ubuntu (as that part is working fine with using apt-get in my playbook for both setting the apt-get source list and installing the package).
  <br/><br/><br/><br/>
  <strong>My question:</strong><br>
  Why ansible facter variable is not setting any valid valid for <code>ansible_distribution_major_release</code> version for Amazon EC2 instance? What <code>facter_*</code>/<code>ansible_*</code> can I use which will work in all 3 OS types. </p>
  
  <p><strong>PS:</strong> When I used <code>baseurl</code>'s value with <code>../el/6/..</code> in it (inside the yum.repos.d/target-pacakge.amazon-os.repo file), yum install worked fine for installing the package on Amazon linux box (though, using <code>../el/7/..</code> in baseurl didn't work). <strong>See here for more details</strong>: <a href="https://packagecloud.io/docs#os_distro_version" rel="nofollow noreferrer">https://packagecloud.io/docs#os_distro_version</a> (under heading: <strong>Enterprise Linux (CentOS, RedHat, Amazon Linux)</strong>)</p>