Calling a secondary inventory file

21 views
Skip to first unread message

Rick Fee

unread,
Jul 21, 2023, 2:56:47 PM7/21/23
to Ansible Project
I looking to see if it is possible to call a inventory file that is built during the playbook?   The role Set mailbox server to inventory file builds a new inventory file and I want to use that in Mailbox Statistics Collection role.   It works and creates the inventory file but does not seem to work, which I have tried both:

 ansible-playbook Mailbox_Count.yml -e site_vars="Creds" --ask-vault-password -v

ansible-playbook -i /etc/ansible/playbooks//sites/Mailbox_Count_Dynamic Mailbox_Count.yml -e site_vars="Creds" --ask-vault-password -v

is this even possible?   Or do I need a first playbook to create the inventory file and the follow-up to grab the mailbox count, so breaking up the below into 2.

- name: Get messaging enviroment
  hosts: localhost
  run_once: true
  roles:
    - Get_Messaging_Environment
  vars_files:
    - /etc/ansible/vars/{{ site_vars }}.yml
  vars:
    ansible_become_user: root
  gather_facts: false

- name: Get the current mailbox server for the environment
  hosts: XU_Server
  become: yes
  become_method: runas
  roles:
    - Get_Mailbox_Servers
  vars_files:
    - /etc/ansible/vars/{{ site_vars }}.yml
  vars:
    ansible_become_user: "{{ Admin_Acct }}"
    ansible_become_pass: "{{ Admin_Pass }}"
  gather_facts: false  

- name: Set mailbox server to inventory file
  hosts: localhost
  run_once: true
  roles:
    - Set_Mailbox_Servers_To_Inventory
  vars_files:
    - /etc/ansible/vars/{{ site_vars }}.yml
  vars:
    ansible_become_user: root
  gather_facts: false

- name: Mailbox Statistics Collection
  hosts: MailboxServers
  become: yes
  become_method: runas
  roles:
    - MailboxServer_Count
  vars_files:
    - /etc/ansible/vars/{{ site_vars }}.yml
    - /etc/ansible/playbooks/Messaging/Exchange_2013/sites/Mailbox_Count_Dynamic
  vars:
    ansible_become_user: "{{ Admin_Acct }}"
    ansible_become_pass: "{{ Admin_Pass }}"
  gather_facts: false

Brian Coca

unread,
Jul 24, 2023, 9:02:05 AM7/24/23
to ansible...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages