Skip to content

Instantly share code, notes, and snippets.

@gavin-romig-koch
Created November 17, 2017 20:44
Show Gist options
  • Save gavin-romig-koch/da8cfe165b6eebb1b626acf0b201988f to your computer and use it in GitHub Desktop.
Save gavin-romig-koch/da8cfe165b6eebb1b626acf0b201988f to your computer and use it in GitHub Desktop.
---
- hosts: all
become: yes
tasks:
- name: Install redhat-access-insights
yum:
name: redhat-access-insights
state: present
register: install_insights_task
- name: If we just installed, also register
when: install_insights_task.changed
command: redhat-access-insights --register
- name: create directory for ansible custom facts
file: state=directory recurse=yes path=/etc/ansible/facts.d
- name: install custom insights fact collection script
copy: src=insights.fact dest=/etc/ansible/facts.d mode=a+x
- name: re-read just the ansible_local facts, which should now contain the insights.system_id
setup: filter=ansible_local
- name: Add Insights System ID as Custom Attribute to Openshift containers provider
manageiq_custom_attributes:
entity_type: 'VM' #i'm not sure what this should be
entity_name: "{{ ansible_hostname }}" # assuming VM's hostname is correct for this
state: 'present'
custom_attributes:
- name: 'insights_system_id'
value: "{{ ansible_local.insights.system_id }}"
miq_url: 'https://miq.example.com'
miq_username: 'dkorn'
miq_password: '******'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment