Ansible Modules:
===============
Ping module
#ansible webservers -m ping -u root -i hosts
Service module -
#ansible webservers -m service -a "name=nginx state=restarted" -u root -i hosts
Shell module -
# ansible webservers -m shell -a "sleep 2s && reboot & executable=/bin/bash" -u root -i hosts
Manual for all the modules
#ansible-doc <module name>
#ansible-doc service
To list all the ansible module
#ansible-doc -l
Ansible command Modules:
=======================
Raw Module - Use for bootstrap server which don't have python installed
#ansible ntpservers -m raw -a "test -e /usr/bin/python || (yum update && yum install python)" -u root -i hosts
#ansible ntpservers -a "who -r" -o -u root -i hosts
Shell Module - To redirect the shell commands
#anisble ntpservers -m shell -a "ps -aux > /tmp/ps.out" -u root -i hosts
Ansible Plugins:
===============
Plugins are pieces of code that augment Ansible's core functionality.
Ansible uses a plugin architecture to enable a rich, flexible and expandable feature set.
Action Plugins, Cache plugins, Inventory Plugins, Lookup Plugins, Vars Plugins, Shell Plugins
Lookup Plugins -
# ansible app -m fetch -a "src='~/.ssh/id_rsa.pub' dest='buffer/{{inventory_hostname}}-id_rsa.pub' flat='yes'" -i ansible_hosts -b --become-user=weblogic
# ansible genf -m authorized_key -a "user=root exclusive=no key='{{ lookup('file', '~/.ssh/id_rsa.pub') }}' "
# ansible app -m authorized_key -a "user='weblogic' state='present' key='{{ lookup('file','buffer/mwiapp01-id_rsa.pub')}}'" --limit=mwiapp02 -i ansible_hosts -b --become-user=weblogic
Inventory Plugins -
https://docs.ansible.com/ansible/latest/plugins/inventory.html
++++++++++Inventory.yml+++++++++++
plugin: constructed
strict: False
groups:
#basic name maching
webservers: inventory_hostname.startwith('web')
dbservers: inventory_hostname.startwith('db')
ntpservers: inventory_hostname.startwith('ntp')
#using ec2 'tags' presupposes AWS inventory
test: "'test' in (ec2_tags|list)"
#complex group membership
multi_group: (group_names|intersection(['alpha', 'beta']))|length >= 2
keyed_groups:
# This creates a group per dist (dest_Centos, dist_Debian) and assigns hosts
# with matching values using the default separator "-"
- prefix: dist
key: ansible_distribution
# this creates a group aligned with ec2 architecture then assigns hosts to
# those that have matching architectures (arch_x86_64, arch_sparc...)
- prefix: arch
key: ec2_architecture
++++++++++++++++++++++++++++++++++++++++++
#ansible-iventory - i hosts -i inventory.yml --list
#ansible-iventory - i hosts -i inventory.yml --graph
Ansible Filters:
===============
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html
Ansible Patterns:
================
#ansible webservers:dbservers -m ping -u root -i hosts
#ansible webserver[0] -m ping -u root -i hosts
#ansible "dbservers:&staging" -m ping -u root -i hosts
#ansible "dbservers:dbservers:&staging:!east" -m ping -u root -i hosts
#ansible "~(web|db)servers" -m ping -u root -i hosts
Command Line Tools:
==================
https://docs.ansible.com/ansible/latest/user_guide/command_line_tools.html
To view the ansible configuration from files
#ansible-config view
To get into the console for all the node
#ansible-console all -u root
To view manual page
#ansible-doc -l -t lookup
#ansible-doc ping
To dump or view the inventory
#ansible-inventory -i hosts --graph
#ansible-inventory -i hosts --list
Network scaling Automation:
==========================
Ansible Tower
Includes important Ansible feature
Complements the mail Ansible application
Adds a comprehensive web-based UI
Powerful for features rendered graphically
Read-time node monitoring
Visual tool reduces indimidation factor
Ansible Tower Main Features
Role-based access control
Simplified portal view mode
Job scheduling
Tower Dashboard
REST API
Cloud Integration
Ansible
IT automation and configuration management
Network automation
Cloud infrastructure integration
Agentless architecture
Simple
Secure
Extensible
Comprehensive
Agentless Architecture
SSH,Netconf,eAPI,NX-API
Centralized automation initiatives
Security compliance
Dyanamic inventory
Use Cases
Grabbing device configurations
Save collection of configurations
Push Device configurations
Upgrade devices
Ansible Tower install:
=====================
umask 022 - Need to set
Minimum 4GB RAM need
===============
Ping module
#ansible webservers -m ping -u root -i hosts
Service module -
#ansible webservers -m service -a "name=nginx state=restarted" -u root -i hosts
Shell module -
# ansible webservers -m shell -a "sleep 2s && reboot & executable=/bin/bash" -u root -i hosts
Manual for all the modules
#ansible-doc <module name>
#ansible-doc service
To list all the ansible module
#ansible-doc -l
Ansible command Modules:
=======================
Raw Module - Use for bootstrap server which don't have python installed
#ansible ntpservers -m raw -a "test -e /usr/bin/python || (yum update && yum install python)" -u root -i hosts
#ansible ntpservers -a "who -r" -o -u root -i hosts
Shell Module - To redirect the shell commands
#anisble ntpservers -m shell -a "ps -aux > /tmp/ps.out" -u root -i hosts
Ansible Plugins:
===============
Plugins are pieces of code that augment Ansible's core functionality.
Ansible uses a plugin architecture to enable a rich, flexible and expandable feature set.
Action Plugins, Cache plugins, Inventory Plugins, Lookup Plugins, Vars Plugins, Shell Plugins
Lookup Plugins -
# ansible app -m fetch -a "src='~/.ssh/id_rsa.pub' dest='buffer/{{inventory_hostname}}-id_rsa.pub' flat='yes'" -i ansible_hosts -b --become-user=weblogic
# ansible genf -m authorized_key -a "user=root exclusive=no key='{{ lookup('file', '~/.ssh/id_rsa.pub') }}' "
# ansible app -m authorized_key -a "user='weblogic' state='present' key='{{ lookup('file','buffer/mwiapp01-id_rsa.pub')}}'" --limit=mwiapp02 -i ansible_hosts -b --become-user=weblogic
Inventory Plugins -
https://docs.ansible.com/ansible/latest/plugins/inventory.html
++++++++++Inventory.yml+++++++++++
plugin: constructed
strict: False
groups:
#basic name maching
webservers: inventory_hostname.startwith('web')
dbservers: inventory_hostname.startwith('db')
ntpservers: inventory_hostname.startwith('ntp')
#using ec2 'tags' presupposes AWS inventory
test: "'test' in (ec2_tags|list)"
#complex group membership
multi_group: (group_names|intersection(['alpha', 'beta']))|length >= 2
keyed_groups:
# This creates a group per dist (dest_Centos, dist_Debian) and assigns hosts
# with matching values using the default separator "-"
- prefix: dist
key: ansible_distribution
# this creates a group aligned with ec2 architecture then assigns hosts to
# those that have matching architectures (arch_x86_64, arch_sparc...)
- prefix: arch
key: ec2_architecture
++++++++++++++++++++++++++++++++++++++++++
#ansible-iventory - i hosts -i inventory.yml --list
#ansible-iventory - i hosts -i inventory.yml --graph
Ansible Filters:
===============
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html
Ansible Patterns:
================
#ansible webservers:dbservers -m ping -u root -i hosts
#ansible webserver[0] -m ping -u root -i hosts
#ansible "dbservers:&staging" -m ping -u root -i hosts
#ansible "dbservers:dbservers:&staging:!east" -m ping -u root -i hosts
#ansible "~(web|db)servers" -m ping -u root -i hosts
Command Line Tools:
==================
https://docs.ansible.com/ansible/latest/user_guide/command_line_tools.html
To view the ansible configuration from files
#ansible-config view
To get into the console for all the node
#ansible-console all -u root
To view manual page
#ansible-doc -l -t lookup
#ansible-doc ping
To dump or view the inventory
#ansible-inventory -i hosts --graph
#ansible-inventory -i hosts --list
Network scaling Automation:
==========================
Ansible Tower
Includes important Ansible feature
Complements the mail Ansible application
Adds a comprehensive web-based UI
Powerful for features rendered graphically
Read-time node monitoring
Visual tool reduces indimidation factor
Ansible Tower Main Features
Role-based access control
Simplified portal view mode
Job scheduling
Tower Dashboard
REST API
Cloud Integration
Ansible
IT automation and configuration management
Network automation
Cloud infrastructure integration
Agentless architecture
Simple
Secure
Extensible
Comprehensive
Agentless Architecture
SSH,Netconf,eAPI,NX-API
Centralized automation initiatives
Security compliance
Dyanamic inventory
Use Cases
Grabbing device configurations
Save collection of configurations
Push Device configurations
Upgrade devices
Ansible Tower install:
=====================
umask 022 - Need to set
Minimum 4GB RAM need
No comments:
Post a Comment