Integrate ansible-cmdb with ansible AWX

915 views
Skip to first unread message

Rajesh Chowdary Samineni

unread,
Jun 9, 2018, 1:27:26 AM6/9/18
to AWX Project
Hi All,

i'm just new to Ansible, I stuck to create a playbook for setup-gather facts.

My requirement is simple.

Play-book for setup-gatherfacts,
which should save the facts each inventory-host in ansible server ( some tmp folder)
i should call those files with ansible-cmdb to create cmdd or shall integrate with ansible-awx 




Kosala Atapattu

unread,
Jun 11, 2018, 12:32:34 AM6/11/18
to rajesh....@gmail.com, AWX Project
Don't think it's possible with any of the modules, but you should be able to do this with a filter plugin.

---


- name: test ansible client, gathering facts

  hosts: "{{ host_group }}"

  become: yes

  become_method: sudo

  tasks:

    - setup:

  register: somevalue | my_filter_to_save(filename)

 
Something like that might fly...

Kosala




--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To post to this group, send email to awx-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/1d810c9a-8cb8-466b-806b-e95ffa09d651%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christopher Meyers

unread,
Jun 11, 2018, 6:27:52 AM6/11/18
to Kosala Atapattu, rajesh....@gmail.com, AWX Project
Awx has a feature called fact caching that saves the result of fact scans to the database on a per host basis. You can turn it on at the job template. The saved facts are accessible via the API.

Rajesh Chowdary Samineni

unread,
Jun 11, 2018, 6:53:24 AM6/11/18
to AWX Project
Let me try this and confirm you.

samineni

unread,
Jun 11, 2018, 7:26:14 AM6/11/18
to kosala....@gmail.com, awx-p...@googlegroups.com
Sorry, i was tried something but didn't workout.

MY Playbook.


---
- hosts:  all
  become: yes
  become_user: root
  become_method: sudo
  tasks:
    - name: gather facts from apps
      setup:
      register: find_output
    - local_action: copy content={{ find_output }} dest=/var/lib/awx/projects/CMDB/{{ inventory_hostname }}



Error In AWX


"msg": "Failed to get information on remote file (/var/lib/awx/projects/CMDB/172.25.1.11): Sorry, try again.\n[sudo via ansible, key=hfzaxausgvjzmfhwxcnoqgyaphcqfqjf] password: \nsudo: 1 incorrect password attempt\n",
    "failed": true
}


Thanks & Regards.......?

Rajesh Samineni


stefan....@gmail.com

unread,
Nov 12, 2020, 8:24:34 AM11/12/20
to AWX Project
Hi,

You can juist delegate the copy task to another server.

---
- hosts: all
  gather_facts: no
  tasks:
    - name: gather facts from apps
      setup:
      register: find_output
    
    - name: save 
      copy: 
        content: "{{ find_output }}" 
        dest: /path/{{ inventory_hostname }}
      delegate_to: someserverawxhasaccessto
    
    - name: Facts have been gathered
      debug:
        msg: "Facts are now gathered"
Reply all
Reply to author
Forward
0 new messages