Made inventories config and scripts
This commit is contained in:
parent
8dbf6cbfd9
commit
3b75cb9f77
@ -12,7 +12,7 @@
|
||||
|
||||
# some basic default values...
|
||||
|
||||
inventory = $HOME/ansible/hosts
|
||||
inventory = $HOME/.secret/.ansible/inventories
|
||||
remote_tmp = $HOME/.ansible/tmp
|
||||
forks = 15
|
||||
sudo_user = root
|
4
ansible/.conf/.config_ssh
Normal file
4
ansible/.conf/.config_ssh
Normal file
@ -0,0 +1,4 @@
|
||||
Host git.hostname.com
|
||||
User git
|
||||
IdentityFile ~/.ssh/id_rsa_git
|
||||
ProxyCommand nc -X connect -x proxy.xxxxxxx.loc:3128 %h %p
|
5
ansible/.conf/.gitconfig
Normal file
5
ansible/.conf/.gitconfig
Normal file
@ -0,0 +1,5 @@
|
||||
[user]
|
||||
name = Name SureName
|
||||
email = xxxxxxx@git.xxxxxx.ru
|
||||
#[core]
|
||||
# autocrlf = input
|
7
ansible/.secret/.ansible/inventories/group_vars/all.yml
Normal file
7
ansible/.secret/.ansible/inventories/group_vars/all.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
## Ansible params
|
||||
ansible_port: '22'
|
||||
ansible_ssh_user: 'root'
|
||||
#ansible_ssh_password: 'XXXXXXXXX'
|
||||
ansible_ssh_private_key_file: '~/.ssh/id_rsa_XXXXXXX'
|
||||
ansible_python_interpreter: '/usr/bin/python3'
|
14
ansible/.secret/.ansible/inventories/hosts
Normal file
14
ansible/.secret/.ansible/inventories/hosts
Normal file
@ -0,0 +1,14 @@
|
||||
[test]
|
||||
|
||||
z3.lab.loc ansible_host=10.8.11.13 ansible_ssh_port=22 ansible_python_interpreter="/usr/bin/python3"
|
||||
|
||||
[all_linux]
|
||||
ovpnsrv01-infr-dmz.lab.loc ansible_host=10.1.1.11 ansible_ssh_port=22 ansible_python_interpreter="/usr/bin/python3"
|
||||
ovpnsrv09-infr-dmz.lab.loc ansible_host=10.1.1.19 ansible_ssh_port=22 ansible_python_interpreter="/usr/bin/python3"
|
||||
websrv99-it-dmz.lab.loc ansible_host=10.1.2.99 ansible_ssh_port=22 ansible_python_interpreter="/usr/bin/python3"
|
||||
svcsrv01-it-dmz.lab.loc ansible_host=10.1.254.254 ansible_ssh_port=22 ansible_python_interpreter="/usr/bin/python3"
|
||||
fakednssrv01-infr.lab.loc ansible_host=10.1.101.101 ansible_ssh_port=22 ansible_python_interpreter="/usr/bin/python3"
|
||||
#autotoolsrv01-it.lab.loc ansible_host=10.1.222.11 ansible_ssh_port=22 ansible_python_interpreter="/usr/bin/python3"
|
||||
lin-reposrv01-it.lab.loc ansible_host=10.1.254.51 ansible_ssh_port=22 ansible_python_interpreter="/usr/bin/python3"
|
||||
rslogsrv01-it.lab.loc ansible_host=10.1.254.2 ansible_ssh_port=22 ansible_python_interpreter="/usr/bin/python3"
|
||||
svcsrv01-it.lab.loc ansible_host=10.1.254.254 ansible_ssh_port=22 ansible_python_interpreter="/usr/bin/python3"
|
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
ansible-inventory -i ~/.secret/.ansible/inventories/vmware_vm_inventory/vmware_vm_inventory.yml --list -y --output ~/.secret/.ansible/inventories/hosts.yml
|
@ -0,0 +1,98 @@
|
||||
---
|
||||
#
|
||||
# For use:
|
||||
# ansible-inventory -i ~/.secret/.ansible/inventories/vmware_vm_inventory/vmware_vm_inventory.yml --list -y --output ~/.secret/.ansible/inventories/hosts_.yml
|
||||
# cat zzz.yml | grep -i "guestid" | sed 's/^ config.guestId: //' | sed 's/$.*//' | sort | uniq
|
||||
#
|
||||
plugin: community.vmware.vmware_vm_inventory
|
||||
strict: true
|
||||
hostname: "vcsrv01.XXXXXXX.XXX"
|
||||
username: "ansb-autotools-it@vsphere.local"
|
||||
password: "XXXXXXXXXXXXXXXX"
|
||||
validate_certs: false
|
||||
with_tags: true
|
||||
with_folders: true
|
||||
with_nested_properties: true
|
||||
|
||||
resources:
|
||||
- datacenter:
|
||||
- 'DC01'
|
||||
resources:
|
||||
- compute_resource:
|
||||
- Cluster01
|
||||
# - folder:
|
||||
# - VLAN-0222
|
||||
|
||||
|
||||
hostnames:
|
||||
- config.name
|
||||
|
||||
properties:
|
||||
- 'name'
|
||||
- 'config.name'
|
||||
- 'guest.guestFamily'
|
||||
- 'guest.guestFullName'
|
||||
# - 'config'
|
||||
# - 'guest'
|
||||
- 'guest.ipAddress'
|
||||
- 'config.guestId'
|
||||
- 'summary.runtime.powerState'
|
||||
- 'config.template'
|
||||
|
||||
## - availableField
|
||||
## - configIssue
|
||||
## - configStatus
|
||||
## - customValue
|
||||
## - datastore
|
||||
## - effectiveRole
|
||||
## - guestHeartbeatStatus
|
||||
## - layout
|
||||
## - layoutEx
|
||||
## - parent
|
||||
## - name
|
||||
## - network
|
||||
## - overallStatus
|
||||
## - parentVApp
|
||||
## - permission
|
||||
## - recentTask
|
||||
## - resourcePool
|
||||
## - rootSnapshot
|
||||
## - snapshot
|
||||
## - triggeredAlarmState
|
||||
## - value
|
||||
## - capability
|
||||
## - config
|
||||
## - guest
|
||||
## - runtime
|
||||
## - storage
|
||||
## - summary
|
||||
|
||||
filters:
|
||||
- config.template == false
|
||||
- summary.runtime.powerState == 'poweredOn'
|
||||
- '"vCLS" not in config.name'
|
||||
- '"vcsrv01.lab.loc" not in config.name'
|
||||
|
||||
#"'Nas01' in config.datastoreUrl[0].name"
|
||||
# or guest.ipAddress is match('192.169.*'))
|
||||
#- config.guestId == 'debian12_64Guest'
|
||||
|
||||
compose:
|
||||
ansible_host: 'guest.ipAddress'
|
||||
# composed_var: 'config.name'
|
||||
# ansible_user: "'root'"
|
||||
# ansible_connection: "'ssh'"
|
||||
# ansible_ssh_private_key_file: "'~/.ssh/id_rsa_XXXXXX'"
|
||||
# ansible_ssh_port: "'22'"
|
||||
# ansible_python_interpreter: "'/usr/bin/python3'"
|
||||
|
||||
groups:
|
||||
VMs: true
|
||||
|
||||
keyed_groups:
|
||||
- key: config.guestId
|
||||
separator: ''
|
||||
- key: guest.guestFullName
|
||||
separator: ''
|
||||
- key: guest.guestFamily
|
||||
separator: ''
|
12
ansible/.secret/.ansible/vars_creds.yml
Normal file
12
ansible/.secret/.ansible/vars_creds.yml
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
vcenter_hostname: "vcs8srv01.lab.loc"
|
||||
vcenter_username: "administrator@vsphere.local"
|
||||
vcenter_password: "XXXXXXXXX"
|
||||
vcenter_validate_certs: false
|
||||
vcenter_datacenter: "DC01"
|
||||
|
||||
ansible_user: "root"
|
||||
#ansible_password: "XXXXXXX"
|
||||
ansible_ssh_private_key_file: '~/.ssh/id_rsa_XXXXXXX'
|
||||
ansible_ssh_port: 22
|
||||
ansible_python_interpreter: "/usr/bin/python3"
|
@ -1,13 +0,0 @@
|
||||
# Inventory gets from VMVare vSphere
|
||||
Add it to you Ansible config file ( /root/.ansible.cfg ):<br/>
|
||||
|
||||
`[inventory]`<br/>
|
||||
`enable_plugins = host_list, script, auto, yaml, ini, toml, community.vmware.vmware_vm_inventory`<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
For use:<br/>
|
||||
|
||||
`ansible-inventory -i /root/ansible/inventories/vmware_vm_inventory.yml --list -y --output zzz.yml`<br/>
|
||||
`cat zzz.yml | grep -i "guestid" | sed 's/^ config.guestId: //' | sed 's/$.*//' | sort | uniq`<br/>
|
||||
<br/>
|
||||
<br/>
|
@ -1,6 +0,0 @@
|
||||
---
|
||||
## Ansible params
|
||||
#ansible_port: '22'
|
||||
#ansible_ssh_user: 'root'
|
||||
#ansible_ssh_password: 'XXXXXXXXX'
|
||||
#ansible_ssh_private_key_file: '~/.ssh/XXXXX.id_rsa'
|
@ -1,17 +0,0 @@
|
||||
|
||||
dc01-ipxesrv01-it-infr.lab.loc ansible_host=10.8.221.2
|
||||
|
||||
z-debian-packer-vm ansible_host=10.8.221.115
|
||||
z-ubuntu-packer-vm ansible_host=10.8.221.118
|
||||
|
||||
aaa ansible_host=10.8.221.200
|
||||
|
||||
|
||||
## Do not edit and delete it ##
|
||||
## It need for packer templetes ##
|
||||
packer-templ-debian-11-x64
|
||||
packer-templ-debian-12-x64
|
||||
packer-templ-ubuntu-24-04-x64
|
||||
## Do not edit and delete it ##
|
||||
## It need for packer templetes ##
|
||||
|
@ -1,45 +0,0 @@
|
||||
---
|
||||
#
|
||||
# For use:
|
||||
# ansible-inventory -i ~/ansible/inventories/vmware_vm_inventory.yml --list -y --output zzz.yml
|
||||
# cat zzz.yml | grep -i "guestid" | sed 's/^ config.guestId: //' | sed 's/$.*//' | sort | uniq
|
||||
#
|
||||
plugin: community.vmware.vmware_vm_inventory
|
||||
strict: true
|
||||
hostname: "vcs8srv01.lab.loc"
|
||||
username: "administrator@vsphere.local"
|
||||
password: "XXXXXXXXX"
|
||||
validate_certs: false
|
||||
with_tags: false
|
||||
with_folders: true
|
||||
|
||||
#resources:
|
||||
# - datacenter:
|
||||
# - 'DC01'
|
||||
# resources:
|
||||
# - compute_resource:
|
||||
# - Cluster01
|
||||
# - folder:
|
||||
# - VLAN-0222
|
||||
|
||||
hostnames:
|
||||
- config.name
|
||||
properties:
|
||||
- name
|
||||
- config.name
|
||||
- guest
|
||||
# - config.guestId
|
||||
- summary.runtime.powerState
|
||||
# - config.datastoreUrl
|
||||
- config.template
|
||||
|
||||
filters:
|
||||
- config.template == false
|
||||
- summary.runtime.powerState == 'poweredOn'
|
||||
|
||||
keyed_groups:
|
||||
- key: summary.runtime.powerState
|
||||
separator: ''
|
||||
|
||||
# - key: ipConfig.network
|
||||
# separator: ''
|
@ -4,6 +4,6 @@
|
||||
become: false
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- /root/.secret/.ansible/vars_creds.yml
|
||||
- ~/.secret/.ansible/vars_creds.yml
|
||||
roles:
|
||||
- os-ipxe-vmware-deploy
|
||||
|
@ -4,7 +4,7 @@
|
||||
become: false
|
||||
gather_facts: true
|
||||
vars_files:
|
||||
- /root/.secret/.ansible/vars_creds.yml
|
||||
- ~/.secret/.ansible/vars_creds.yml
|
||||
tasks:
|
||||
- name: Upgrage system type of Debian using apt
|
||||
block:
|
||||
|
@ -4,7 +4,7 @@
|
||||
become: false
|
||||
gather_facts: true
|
||||
vars_files:
|
||||
- /root/.secret/.ansible/vars_creds.yml
|
||||
- ~/.secret/.ansible/vars_creds.yml
|
||||
|
||||
tasks:
|
||||
- name: Debug
|
||||
|
@ -7,7 +7,7 @@
|
||||
vars_name: "dc01-ftpsrv01-it-infr.lab.loc"
|
||||
# vars_name: "debian12-common-templ"
|
||||
vars_files:
|
||||
- /root/.secret/.ansible/vars_creds.yml
|
||||
- ~/.secret/.ansible/vars_creds.yml
|
||||
|
||||
tasks:
|
||||
- name: Get info VM
|
||||
|
@ -7,7 +7,7 @@
|
||||
vars_name: "dc01-ftpsrv01-it-infr.lab.loc"
|
||||
# vars_name: "debian12-common-templ"
|
||||
vars_files:
|
||||
- /root/.secret/.ansible/vars_creds.yml
|
||||
- ~/.secret/.ansible/vars_creds.yml
|
||||
|
||||
tasks:
|
||||
- name: Get info VM
|
||||
|
Loading…
x
Reference in New Issue
Block a user