Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 52.14.127.77
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/ansible_collections/cisco/intersight/playbooks/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/python3/dist-packages/ansible_collections/cisco/intersight/playbooks/update_all_inventory.yml
---
#
# Summary: Auto generate (or update) the Ansible inventory file with all servers (Name and Moid or each discovered server)
#
# The hosts group used is provided by the group variable or defaulted to 'Intersight'.
# You can specify a specific host (or host group) on the command line:
#   ansible-playbook ... -e group=<your host group>
#   e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
# This playbook only runs once (and not for each server in the inventory), but the hosts group is used to get API key info
#
- hosts: "{{ group | default('Intersight') }}"
  connection: local
  gather_facts: false
  vars:
    # Create an anchor for api_info that can be used throughout the file
    api_info: &api_info
      # if api_key vars are omitted, INTERSIGHT_API_KEY_ID, INTERSIGHT_API_PRIVATE_KEY,
      # and INTERSIGHT_API_URI environment variables used for API key data
      api_private_key: "{{ api_private_key | default(omit) }}"
      api_key_id: "{{ api_key_id | default(omit)  }}"
      api_uri: "{{ api_uri | default(omit) }}"
      validate_certs: "{{ validate_certs | default(omit) }}"
      state: "{{ state | default(omit) }}"
    # Change filepath if you want to update a different inventory file
    filepath: "{{ inventory_file }}"
    # Change host_group if you want to use another group name for your servers in the created inventory
    host_group: Intersight_Servers
  tasks:
    # Enclose tasks in a block that is only run once
    - block:
        # Find all servers
        - cisco.intersight.intersight_info:
            <<: *api_info
            server_names:
          register: all_results
        # Place the servers in a group in the file
        - debug:
            msg: Inventory filepath "{{ filepath }}"
        - lineinfile:
            path: "{{ filepath }}"
            line: "[{{ host_group }}]"
            create: true
        # Update servers in the file
        - lineinfile:
            path: "{{ filepath }}"
            insertafter: "^\\[{{ host_group }}\\]"
            regexp: "^{{ item.Name }} serial={{ item.Serial }} "
            # Each line of the inventory has the following:
            line: "{{ item.Name }} serial={{ item.Serial }} server_moid={{ item.Moid }} model={{ item.Model }} mode={{ item.ManagementMode }} object_type={{ item.SourceObjectType | regex_replace('compute.')}}"
            create: true
          loop: "{{ all_results.intersight_servers }}"
          loop_control:
            label: "{{ item.Name }}"
          when: all_results.intersight_servers is defined
      delegate_to: localhost
      run_once: true

Anon7 - 2022
AnonSec Team