Ansible
1) Introduction to Ansible
-Provisioning
-Configuration
-Continuous Delivery
-Application Deployment
-Security Compliance
-simple
-agentless
-one basic dependency - python
-config in YAML and jinja2
https://docs.ansible.com/
https://docs.ansible.com/ansible/2.6/user_guide/intro_getting_started.html
-agentless
2) Setting up Ansible
Lab enviornment
Template
-Ansible Control Machine (ansible-controller
-Ansible Target Machine (target01)
-Ansible Target Machine (target02)
https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#latest-release-via-dnf-or-yum
Ansible Troubleshooting Tips
Assumtions about control machine - requierments
- Python 6 or 7
- windows cannot be control machine ( ansible supports Windows as a target machine - you can use Aspel)
- control machine has to have ssh connection to target machines
-x ansible run as wiil have super user access on your posts. (this is not a strict requierment to actually run ansible and still can run without super user access, but since we are doing configuration managment systems configuration it is almost given that at some point you are going to need do something that requiers sudo or root or super user access)
3) Introduction to YAML
a) Key Value Pair
Fruit: Apple
Vegetable: Carrot
Liquid: Water
Meat: Chicken
b) Array/List
Fruits:
- Orange
- Apple
- Banana
Vegetables:
- Carrot
- Cauliflower
- Tomato
c) Dictionary/Map
Banana:
Calories: 105
Fat: 0.4 g
Carbs: 27 g
Grapes:
Calories: 62
Fat: 0.3 g
Carbs: 16 g
d) Dictionary vs List vs list of Directionary
Dictionary - unordered
List Ordered
# - comment
4) Ansible Inventory Files
-stores information about target machine
-default inventory /etc/ansible/hosts
#Sample Inventory File
server1.company.com
server2.company.com
[mail]
server3.company.com
server4.company.com
[db]
server5.company.com
server6.company.com
[web]
server7.company.com
server8.company.com
[all_servers:children]
mail
db
web
#Sample Inventory File
web ansible_host=server1.company.com
db ansible_host=server2.company.com ansible_connection=winrm
localhost ansible_connection=localhost
Inventory Parameters:
-ansible_connection - ssh/winrm/localhost
-ansible_port - 22/5986
-ansible_user - root/administrator
-ansible_ssh_pass - password Linux
-ansible_password - password Windows
Ansible Vault - Security
cat inventory.txt
ansibletarget1 ansible_host=192.168.7.109 ansible_ssh_pass=osboxes.org
ansibletarget2 ansible_host=192.168.7.108 ansible_ssh_pass=osboxes.org
ansible ansibletarget2 -m ping -i inventory.txt
ansibletarget2 | SUCCESS => {
"changed": false,
"ping": "pong"
}
ansible ansibletarget1 -m ping -i inventory.txt
ansibletarget1 | FAILED! => {
"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."
}
ERROR
Solution 1: ssh to target machine
Solution 2: change config vi /etc/ansible/ansible.cfg un comment host_key_checking = false
-> nie rekomentowane na produkcji
5) Ansible Playbooks
Playbook - A single YAML file
Play - Defines a set of activites (tasks) to be run on hosts
Tasks - an action to be performed on the host
-execute a command
-run a script
-install a package
-shutdown/restart
#Simple Ansible Playbook1.yml
-
name: Play 1
hosts: localhost
tasks:
- name: Execute command 'date'
command: date
- name: Execute script on server
script: test_script.sh
-
name: Play 2
hosts: localhost
tasks:
- name: Install httpd service
yum:
name: httpd
state: present
- name: Start web server
service:
name: httpd
state: started
ansible-doc -l #list commands avaible
Execute Ansible Playbook
Syntax: ansible-playbook <playbook file name>
ansible-playbook playbook.yml
ansible-playbook --help
Running ansible
a) ansible
ansible <hosts> -a <command>
ansible all -a "/sbin/reboot"
ansible <hosts> -m <module>
-Provisioning
-Configuration
-Continuous Delivery
-Application Deployment
-Security Compliance
-simple
-agentless
-one basic dependency - python
-config in YAML and jinja2
https://docs.ansible.com/
https://docs.ansible.com/ansible/2.6/user_guide/intro_getting_started.html
-agentless
2) Setting up Ansible
Lab enviornment
Template
-Ansible Control Machine (ansible-controller
-Ansible Target Machine (target01)
-Ansible Target Machine (target02)
https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#latest-release-via-dnf-or-yum
Ansible Troubleshooting Tips
Issues installing Ansible and its dependencies
Once the Debian VM is up and running make the following changes to the /etc/apt/sources.list file to get the Ansible installation working right.
- Comment the line starting deb cdrom
- Uncomment bottom two lines starting deb and deb-src
- Add the below two lines:
- deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main
- deb http://ftp.de.debian.org/debian sid main
Final file:
- #
- # deb cdrom:[Debian GNU/Linux 8.9.0 _Jessie_ - Official amd64 DVD Binary-1 20170723-11:49]/ jessie contrib main
- #deb cdrom:[Debian GNU/Linux 8.9.0 _Jessie_ - Official amd64 DVD Binary-1 20170723-11:49]/ jessie contrib main
- #deb http://deb/debian.org/debian jessie main
- #deb-src http://deb.debian.org/debian stretch main
- deb http://security.debian.org/ jessie/updates main contrib
- deb-src http://security.debian.org/ jessie/updates main contrib
- # jessie-updates, previously known as 'volatile'
- # A network mirror was not selected during install. The following entries
- # are provided as examples, but you should amend them as appropriate
- # for your mirror of choice.
- #
- deb http://ftp.debian.org/debian/ jessie-updates m
Assumtions about control machine - requierments
- Python 6 or 7
- windows cannot be control machine ( ansible supports Windows as a target machine - you can use Aspel)
- control machine has to have ssh connection to target machines
-x ansible run as wiil have super user access on your posts. (this is not a strict requierment to actually run ansible and still can run without super user access, but since we are doing configuration managment systems configuration it is almost given that at some point you are going to need do something that requiers sudo or root or super user access)
3) Introduction to YAML
a) Key Value Pair
Fruit: Apple
Vegetable: Carrot
Liquid: Water
Meat: Chicken
b) Array/List
Fruits:
- Orange
- Apple
- Banana
Vegetables:
- Carrot
- Cauliflower
- Tomato
c) Dictionary/Map
Banana:
Calories: 105
Fat: 0.4 g
Carbs: 27 g
Grapes:
Calories: 62
Fat: 0.3 g
Carbs: 16 g
d) Dictionary vs List vs list of Directionary
Dictionary - unordered
List Ordered
# - comment
4) Ansible Inventory Files
-stores information about target machine
-default inventory /etc/ansible/hosts
#Sample Inventory File
server1.company.com
server2.company.com
[mail]
server3.company.com
server4.company.com
[db]
server5.company.com
server6.company.com
[web]
server7.company.com
server8.company.com
[all_servers:children]
db
web
#Sample Inventory File
web ansible_host=server1.company.com
db ansible_host=server2.company.com ansible_connection=winrm
localhost ansible_connection=localhost
Inventory Parameters:
-ansible_connection - ssh/winrm/localhost
-ansible_port - 22/5986
-ansible_user - root/administrator
-ansible_ssh_pass - password Linux
-ansible_password - password Windows
Ansible Vault - Security
cat inventory.txt
ansibletarget1 ansible_host=192.168.7.109 ansible_ssh_pass=osboxes.org
ansibletarget2 ansible_host=192.168.7.108 ansible_ssh_pass=osboxes.org
ansible ansibletarget2 -m ping -i inventory.txt
ansibletarget2 | SUCCESS => {
"changed": false,
"ping": "pong"
}
ansible ansibletarget1 -m ping -i inventory.txt
ansibletarget1 | FAILED! => {
"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."
}
ERROR
Solution 1: ssh to target machine
Solution 2: change config vi /etc/ansible/ansible.cfg un comment host_key_checking = false
-> nie rekomentowane na produkcji
5) Ansible Playbooks
Playbook - A single YAML file
Play - Defines a set of activites (tasks) to be run on hosts
Tasks - an action to be performed on the host
-execute a command
-run a script
-install a package
-shutdown/restart
#Simple Ansible Playbook1.yml
-
name: Play 1
hosts: localhost
tasks:
- name: Execute command 'date'
command: date
- name: Execute script on server
script: test_script.sh
-
name: Play 2
hosts: localhost
tasks:
- name: Install httpd service
yum:
name: httpd
state: present
- name: Start web server
service:
name: httpd
state: started
ansible-doc -l #list commands avaible
Execute Ansible Playbook
Syntax: ansible-playbook <playbook file name>
ansible-playbook playbook.yml
ansible-playbook --help
Running ansible
a) ansible
ansible <hosts> -a <command>
ansible all -a "/sbin/reboot"
ansible <hosts> -m <module>
ansible database -i inventory - m apt -a "name=mysql-server state=present"
ansible target1 -m ping
ansible all -m ping -i inventory.txt
b) ansible-playbook
ansible-playbook <playbook name>
cat playbook-pingtest.yml
-
name: Test connectivity to target servers
hosts: all
tasks:
- name: Ping test
ping:
ansible-playbook playbook-pingtest.yml -i inventory.txt
6) Modules
a)System
b)Commands
-executes a command on a remote node
#Sample Ansible Playbook1.yml
-
name: Play 1
hosts: localhost
tasks:
- name: Execute command 'date'
command: date
- name: Display resolv.conf contents
command: cat /etc/resolv.conf
- name: Display resolv.conf contents
command: cat /etc/resolv.con chdir=/etc
#change into /etc directoy before running
- name: Display resolv.conf contents
command: mkdir /folder creates=/folder
#run only if folder does not exist
c)Files
-runs a loclal script on a remote node after transfering it
1. copy script to remote systems
2. Execute script on remote systems
#Sample Ansible Playbook1.yml
-
name: Play 1
hosts: localhost
tasks:
- name: run a script on remots server
script: /some/local/script.sh -arg1 -arg2
lineinfile
-search for a line in a file and replace it or add it if it doesn't exist
#Sample /etc/resolv.conf
nameserver 10.1.250.1
nameserver 10.1.250.2
nameserver 10.1.250.10
#Sample Ansible Playbook1.yml
-
name: Add DNS server to resolv.conf
hosts: localhost
tasks:
- lineinfile:
path: /etc/resolv.conf
line: 'nameserver 10.1.250.10'
#Sample script
echo "nameserver 10.1.250.10" >> /etc/resolv.conf
-ansible insure that is only ojne entry in file , script will keep adding them with every run
d)Database
e)Cloud
Google
f)Windows
g) more..
7) Variables
-store information that varies with each host
a) in inventory
#Sample Inventory File
web ansible_host=server1.company.com
db ansible_host=server2.company.com ansible_connection=winrm
b) in playbook
#Sample Ansible Playbook1.yml
-
name: Add DNS server to resolv.conf
hosts: localhost
vars:
dns_server: 10.1.250.10
tasks:
- lineinfile:
path: /etc/resolv.conf
line: 'nameserver {{ dns_server }}'
c) in variable files
#Sample Variable_file.yml
variable1: value1
variable2: value2
Jinja2 templating
source: '{{ inter_ip_range }}'
8) Conditionals
#Sample Inventory File
web1 ansible_host=server1.company.com
db ansible_host=db.company.com ansible_connection=winrm
web2 ansible_host=server2.company.com
[all_servers]
web1
db
web2
#Sample Ansible Playbook1.yml
-
name: Start services hosts: localhost
hosts: all_servers
tasks:
-
service: name=mysql state=started
when: ansible_host == db.company.com
-
service: name=httpd state=started
when: ansible_host =='server1.company.com' or ansible_host =='server2.company.com'
#Sample Ansible Playbook1.yml
-
name: Check status of service and email if its down
hosts: localhost
tasks:
-
command: service httpd status
register: command_output
-
mail:
to: Admins <system.admins@company.com>
subject: Service Alert
body: 'Service {{ ansible_hostname }} is down.'
when: command_output.stdout.find('down') != -1
https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html
9) Loops
a) with_items
#Sample Ansible Playbook1.yml
-
name: Install Packages
hosts: localhost
tasks:
-
yum: name='{{ item }}' state=present
with_items:
- httpd
- binutils
- glibc
10) Roles
a) include
-include <playbook name>
b) include tasks and vars
tasks:
- include: tasks.yml
vars_files:
- variables.yml
roles:
-webservers
Ansible Project
inventory.txt.
setup_application.yml
roles
webservers
files
templates
11) Preparing Windows Server
-Ansible Control Machine can only be Linux and not Windows
-Windows machines can be targets of Ansible and thus be part of automation
-Ansible connects to a windows machine using winrm
-Requirement:
*pywinrm module installed on the Ansible Control Machine - pip install "pywinrm>=0.2.2"
*Setup WinRM - examples/scripts/ConfigureRemotingForAnsible.ps1
*Different modes of authentication:
** Basic/Certificatwe/Kerberos/NTLM/CredSSP
12) Ansible-Galaxy
https://galaxy.ansible.com/
13) Patterns
hosts : localhost
-host1, host2, host3
-group1, host1
-host*
-*.company.com
https://docs.ansible.com/ansible/2.6/user_guide/intro_patterns.html
14) Dynamic Inventory
ansible-playbook -i inventory.txt playbook.yml
ansible-playbook -i inventory.py playbook.yml
15) Developing Custom Modules
https://docs.ansible.com/ansible/2.5/dev_guide/developing_modules.html
16)Web Application
1. Identify Server
2. Python
3. Install Configure Start
4. Install Flask
5. source Code
6. Run
https://github.com/mmumshad/simple-webapp
# Inventory file
db_and_web_server1 ansible_ssh_pass=Passw0rd ansible_host=192.168.1.6
db_and_web_server2 ansible_ssh_pass=Passw0rd ansible_host=192.168.1.15
#Ansible Playbook
-
name: Deploy Web Application
hosts: db_and_web_server*
tasks:
- name: Install dependecies
apt: name={{ item }} state=installed
with_items:
- python-setuptools
- python-dev
- build-essential
- python-pip
- python-mysqldb
- name: Install MySQL database
apt: name={{ item }} state=installed
with_items:
- mysql-server
- mysql-client
- name: Start Mysql Service
service:
name: mysql
state: started
enabled: yes
- name: Create Application Database
mysql_db: name=employee_db state=present
- name: Create Application DB User
mysql_user:
name: db_user
password: Passw0rd
priv: '*.*:ALL'
state: present
host: '%'
- name: Install Python Flask dependencies
pip:
name: {{ item }}
state: present
with_items:
- flask
- flask-mysql
- name: Copy web-server code
copy: src=app.py dest=/opt/app.py
- name: Run web-server
shell FLASK_APP=/opt/app.py nohup flask run --host=0.0.0.0
#app.py
17) Asynchronous Actions
18) Error Handling
19) Jinja 2 Templating
20) Lookups
21) Vault
22) Dynamic Inventory
23) Custom Modules
24) Plugins
25) Practice
26) playable
sudo docker run -p 80:8080 mmumshad/ansible-playable
ansible target1 -m ping
ansible all -m ping -i inventory.txt
b) ansible-playbook
ansible-playbook <playbook name>
cat playbook-pingtest.yml
-
name: Test connectivity to target servers
hosts: all
tasks:
- name: Ping test
ping:
ansible-playbook playbook-pingtest.yml -i inventory.txt
6) Modules
a)System
- aix_inittab - Manages the inittab on AIX
- aix_lvol - Configure AIX LVM logical volumes
- alternatives - Manages alternative programs for common commands
- at - Schedule the execution of a command or script file via the at command
- authorized_key - Adds or removes an SSH authorized key
- awall - Manage awall policies
- beadm - Manage ZFS boot environments on FreeBSD/Solaris/illumos systems.
- capabilities - Manage Linux capabilities
- cron - Manage cron.d and crontab entries
- cronvar - Manage variables in crontabs
- crypttab - Encrypted Linux block devices
- dconf - Modify and read dconf database
- debconf - Configure a .deb package
- facter - Runs the discovery program facter on the remote system
- filesystem - Makes a filesystem
- firewalld - Manage arbitrary ports/services with firewalld
- gconftool2 - Edit GNOME Configurations
- getent - A wrapper to the unix getent utility
- gluster_volume - Manage GlusterFS volumes
- group - Add or remove groups
- hostname - Manage hostname
- interfaces_file - Tweak settings in /etc/network/interfaces files
- iptables - Modify the systems iptables
- java_cert - Uses keytool to import/remove key from java keystore(cacerts)
- kernel_blacklist - Blacklist kernel modules
- known_hosts - Add or remove a host from the known_hosts file
- locale_gen - Creates or removes locales
- lvg - Configure LVM volume groups
- lvol - Configure LVM logical volumes
- make - Run targets in a Makefile
- mksysb - Generates AIX mksysb rootvg backups.
- modprobe - Load or unload kernel modules
- mount - Control active and configured mount points
- nosh - Manage services with nosh
- ohai - Returns inventory data from Ohai
- open_iscsi - Manage iscsi targets with open-iscsi
- openwrt_init - Manage services on OpenWrt.
- osx_defaults - osx_defaults allows users to read, write, and delete Mac OS X user defaults from Ansible
- pam_limits - Modify Linux PAM limits
- pamd - Manage PAM Modules
- parted - Configure block device partitions
- ping - Try to connect to host, verify a usable python and return pong on success
- puppet - Runs puppet
- runit - Manage runit services
- seboolean - Toggles SELinux booleans
- sefcontext - Manages SELinux file context mapping definitions
- selinux - Change policy and state of SELinux
- selinux_permissive - Change permissive domain in SELinux policy
- seport - Manages SELinux network port type definitions
- service - Manage services
- service_facts - Return service state information as fact data
- setup - Gathers facts about remote hosts
- solaris_zone - Manage Solaris zones
- svc - Manage daemontools services
- sysctl - Manage entries in sysctl.conf.
- systemd - Manage services
- sysvinit - Manage SysV services.
- timezone - Configure timezone setting
- ufw - Manage firewall with UFW
- user - Manage user accounts
- vdo - Module to control VDO
service
-manage services - Start, Stop, Restart
#Sample Ansible Playbook1.yml
-
name: Start Services in order
hosts: localhost
tasks:
- name: Start the database service
service: name=postgresql state=started
- name: Start the httpd service
service: name=httpd state=started
- name: Start the nginx service
service: name=nginx state=started
#Sample Ansible Playbook1.yml
-
name: Start Services in order
hosts: localhost
tasks:
- name: Start the database service
service:
name: postgresql
state: started
-Why "started" and not "start"
Ensure service httpd is started
if httpd is not already started -> start it
if httpd is already started -> do nothing
b)Commands
- command - Executes a command on a remote node
- expect - Executes a command and responds to prompts.
- raw - Executes a low-down and dirty SSH command
- script - Runs a local script on a remote node after transferring it
- shell - Execute commands in nodes.
- telnet - Executes a low-down and dirty telnet command
-executes a command on a remote node
- The
commandmodule takes the command name followed by a list of space-delimited arguments. - The given command will be executed on all selected nodes. It will not be processed through the shell, so variables like
$HOMEand operations like"<",">","|",";"and"&"will not work (use the shell module if you need these features). - For Windows targets, use the win_command module instead.
| Parameter | Choices/Defaults | Comments |
|---|---|---|
| argv
(added in 2.6)
|
Allows the user to provide the command as a list vs. a string. Only the string or the list form can be provided, not both. One or the other must be provided.
| |
| chdir |
Change into this directory before running the command.
| |
| creates |
A filename or (since 2.0) glob pattern, when it already exists, this step will not be run.
| |
| free_form
required
|
The command module takes a free form command to run. There is no parameter actually named 'free form'. See the examples!
| |
| removes |
A filename or (since 2.0) glob pattern, when it does not exist, this step will not be run.
| |
| stdin
(added in 2.4)
|
Set the stdin of the command directly to the specified value.
| |
| warn
bool
(added in 1.8)
|
|
If command_warnings are on in ansible.cfg, do not warn about this particular line if set to
no. |
#Sample Ansible Playbook1.yml
-
name: Play 1
hosts: localhost
tasks:
- name: Execute command 'date'
command: date
- name: Display resolv.conf contents
command: cat /etc/resolv.conf
- name: Display resolv.conf contents
command: cat /etc/resolv.con chdir=/etc
#change into /etc directoy before running
- name: Display resolv.conf contents
command: mkdir /folder creates=/folder
#run only if folder does not exist
c)Files
- acl - Sets and retrieves file ACL information.
- archive - Creates a compressed archive of one or more files or trees
- assemble - Assembles a configuration file from fragments
- blockinfile - Insert/update/remove a text block surrounded by marker lines
- copy - Copies files to remote locations
- fetch - Fetches a file from remote nodes
- file - Sets attributes of files
- find - Return a list of files based on specific criteria
- ini_file - Tweak settings in INI files
- iso_extract - Extract files from an ISO image
- lineinfile - Manage lines in text files
- patch - Apply patch files using the GNU patch tool
- replace - Replace all instances of a particular string in a file using a back-referenced regular expression.
- stat - Retrieve file or file system status
- synchronize - A wrapper around rsync to make common tasks in your playbooks quick and easy.
- tempfile - Creates temporary files and directories.
- template - Templates a file out to a remote server
- unarchive - Unpacks an archive after (optionally) copying it from the local machine.
- xattr - Manage user defined extended attributes
- xml - Manage bits and pieces of XML files or strings
-runs a loclal script on a remote node after transfering it
1. copy script to remote systems
2. Execute script on remote systems
#Sample Ansible Playbook1.yml
-
name: Play 1
hosts: localhost
tasks:
- name: run a script on remots server
script: /some/local/script.sh -arg1 -arg2
lineinfile
-search for a line in a file and replace it or add it if it doesn't exist
#Sample /etc/resolv.conf
nameserver 10.1.250.1
nameserver 10.1.250.2
nameserver 10.1.250.10
#Sample Ansible Playbook1.yml
-
name: Add DNS server to resolv.conf
hosts: localhost
tasks:
- lineinfile:
path: /etc/resolv.conf
line: 'nameserver 10.1.250.10'
#Sample script
echo "nameserver 10.1.250.10" >> /etc/resolv.conf
-ansible insure that is only ojne entry in file , script will keep adding them with every run
d)Database
Influxdb
Misc
Mongodb
Mysql
Postgresql
- postgresql_db - Add or remove PostgreSQL databases from a remote host.
- postgresql_ext - Add or remove PostgreSQL extensions from a database.
- postgresql_lang - Adds, removes or changes procedural languages with a PostgreSQL database.
- postgresql_privs - Grant or revoke privileges on PostgreSQL database objects.
- postgresql_schema - Add or remove PostgreSQL schema from a remote host
- postgresql_user - Adds or removes a users (roles) from a PostgreSQL database.
Proxysql
- proxysql_backend_servers - Adds or removes mysql hosts from proxysql admin interface.
- proxysql_global_variables - Gets or sets the proxysql global variables.
- proxysql_manage_config - Writes the proxysql configuration settings between layers.
- proxysql_mysql_users - Adds or removes mysql users from proxysql admin interface.
- proxysql_query_rules - Modifies query rules using the proxysql admin interface.
- proxysql_replication_hostgroups - Manages replication hostgroups using the proxysql admin interface.
- proxysql_scheduler - Adds or removes schedules from proxysql admin interface.
Vertica
- vertica_configuration - Updates Vertica configuration parameters.
- vertica_facts - Gathers Vertica database facts.
- vertica_role - Adds or removes Vertica database roles and assigns roles to them.
- vertica_schema - Adds or removes Vertica database schema and roles.
- vertica_user - Adds or removes Vertica database users and assigns roles.
e)Cloud
Amazon
- aws_acm_facts - Retrieve certificate facts from AWS Certificate Manager service
- aws_api_gateway - Manage AWS API Gateway APIs
- aws_application_scaling_policy - Manage Application Auto Scaling Scaling Policies
- aws_az_facts - Gather facts about availability zones in AWS.
- aws_batch_compute_environment - Manage AWS Batch Compute Environments
- aws_batch_job_definition - Manage AWS Batch Job Definitions
- aws_batch_job_queue - Manage AWS Batch Job Queues
- aws_caller_facts - Get facts about the user and account being used to make AWS calls.
- aws_config_aggregation_authorization - Manage cross-account AWS Config authorizations
- aws_config_aggregator - Manage AWS Config aggregations across multiple accounts
- aws_config_delivery_channel - Manage AWS Config delivery channels
- aws_config_recorder - Manage AWS Config Recorders
- aws_config_rule - Manage AWS Config resources
- aws_direct_connect_connection - Creates, deletes, modifies a DirectConnect connection
- aws_direct_connect_gateway - Manage AWS Direct Connect Gateway.
- aws_direct_connect_link_aggregation_group - Manage Direct Connect LAG bundles.
- aws_direct_connect_virtual_interface - Manage Direct Connect virtual interfaces.
- aws_elasticbeanstalk_app - create, update, and delete an elastic beanstalk application
- aws_glue_connection - Manage an AWS Glue connection
- aws_glue_job - Manage an AWS Glue job
- aws_inspector_target - Create, Update and Delete Amazon Inspector Assessment Targets
- aws_kms - Perform various KMS management tasks.
- aws_kms_facts - Gather facts about AWS KMS keys
- aws_region_facts - Gather facts about AWS regions.
- aws_s3 - manage objects in S3.
- aws_s3_bucket_facts - Lists S3 buckets in AWS
- aws_s3_cors - Manage CORS for S3 buckets in AWS
- aws_ses_identity - Manages SES email and domain identity
- aws_ses_identity_policy - Manages SES sending authorization policies
- aws_sgw_facts - Fetch AWS Storage Gateway facts
- aws_ssm_parameter_store - Manage key-value pairs in aws parameter store.
- aws_waf_condition - create and delete WAF Conditions
- aws_waf_facts - Retrieve facts for WAF ACLs, Rule , Conditions and Filters.
- aws_waf_rule - create and delete WAF Rules
- aws_waf_web_acl - create and delete WAF Web ACLs
- cloudformation - Create or delete an AWS CloudFormation stack
- cloudformation_facts - Obtain facts about an AWS CloudFormation stack
- cloudfront_distribution - create, update and delete aws cloudfront distributions.
- cloudfront_facts - Obtain facts about an AWS CloudFront distribution
- cloudfront_invalidation - create invalidations for aws cloudfront distributions
- cloudfront_origin_access_identity - create, update and delete origin access identities for a cloudfront distribution.
- cloudtrail - manage CloudTrail create, delete, update
- cloudwatchevent_rule - Manage CloudWatch Event rules and targets
- cloudwatchlogs_log_group - create or delete log_group in CloudWatchLogs
- cloudwatchlogs_log_group_facts - get facts about log_group in CloudWatchLogs
- data_pipeline - Create and manage AWS Datapipelines
- dynamodb_table - Create, update or delete AWS Dynamo DB tables.
- dynamodb_ttl - set TTL for a given DynamoDB table.
- ec2 - create, terminate, start or stop an instance in ec2
- ec2_ami - create or destroy an image in ec2
- ec2_ami_copy - copies AMI between AWS regions, return new image id
- ec2_ami_facts - Gather facts about ec2 AMIs
- ec2_ami_find - Searches for AMIs to obtain the AMI ID and other information (D)
- ec2_ami_search - Retrieve AWS AMI information for a given operating system. (D)
- ec2_asg - Create or delete AWS Autoscaling Groups
- ec2_asg_facts - Gather facts about ec2 Auto Scaling Groups (ASGs) in AWS
- ec2_asg_lifecycle_hook - Create, delete or update AWS ASG Lifecycle Hooks.
- ec2_customer_gateway - Manage an AWS customer gateway
- ec2_customer_gateway_facts - Gather facts about customer gateways in AWS
- ec2_eip - manages EC2 elastic IP (EIP) addresses.
- ec2_eip_facts - List EC2 EIP details
- ec2_elb - De-registers or registers instances from EC2 ELBs
- ec2_elb_facts - Gather facts about EC2 Elastic Load Balancers in AWS
- ec2_elb_lb - Creates or destroys Amazon ELB.
- ec2_eni - Create and optionally attach an Elastic Network Interface (ENI) to an instance
- ec2_eni_facts - Gather facts about ec2 ENI interfaces in AWS
- ec2_group - maintain an ec2 VPC security group.
- ec2_group_facts - Gather facts about ec2 security groups in AWS.
- ec2_instance - Create & manage EC2 instances
- ec2_instance_facts - Gather facts about ec2 instances in AWS
- ec2_key - create or delete an ec2 key pair
- ec2_lc - Create or delete AWS Autoscaling Launch Configurations
- ec2_lc_facts - Gather facts about AWS Autoscaling Launch Configurations
- ec2_lc_find - Find AWS Autoscaling Launch Configurations
- ec2_metadata_facts - Gathers facts (instance metadata) about remote hosts within ec2
- ec2_metric_alarm - Create/update or delete AWS Cloudwatch ‘metric alarms’
- ec2_placement_group - Create or delete an EC2 Placement Group
- ec2_placement_group_facts - List EC2 Placement Group(s) details
- ec2_remote_facts - Gather facts about ec2 instances in AWS (D)
- ec2_scaling_policy - Create or delete AWS scaling policies for Autoscaling groups
- ec2_snapshot - creates a snapshot from an existing volume
- ec2_snapshot_copy - copies an EC2 snapshot and returns the new Snapshot ID.
- ec2_snapshot_facts - Gather facts about ec2 volume snapshots in AWS
- ec2_tag - create and remove tag(s) to ec2 resources.
- ec2_vol - create and attach a volume, return volume id and device map
- ec2_vol_facts - Gather facts about ec2 volumes in AWS
- ec2_vpc - configure AWS virtual private clouds (D)
- ec2_vpc_dhcp_option - Manages DHCP Options, and can ensure the DHCP options for the given VPC match what’s requested
- ec2_vpc_dhcp_option_facts - Gather facts about dhcp options sets in AWS
- ec2_vpc_egress_igw - Manage an AWS VPC Egress Only Internet gateway
- ec2_vpc_endpoint - Create and delete AWS VPC Endpoints.
- ec2_vpc_endpoint_facts - Retrieves AWS VPC endpoints details using AWS methods.
- ec2_vpc_igw - Manage an AWS VPC Internet gateway
- ec2_vpc_igw_facts - Gather facts about internet gateways in AWS
- ec2_vpc_nacl - create and delete Network ACLs.
- ec2_vpc_nacl_facts - Gather facts about Network ACLs in an AWS VPC
- ec2_vpc_nat_gateway - Manage AWS VPC NAT Gateways.
- ec2_vpc_nat_gateway_facts - Retrieves AWS VPC Managed Nat Gateway details using AWS methods.
- ec2_vpc_net - Configure AWS virtual private clouds
- ec2_vpc_net_facts - Gather facts about ec2 VPCs in AWS
- ec2_vpc_peer - create, delete, accept, and reject VPC peering connections between two VPCs.
- ec2_vpc_peering_facts - Retrieves AWS VPC Peering details using AWS methods.
- ec2_vpc_route_table - Manage route tables for AWS virtual private clouds
- ec2_vpc_route_table_facts - Gather facts about ec2 VPC route tables in AWS
- ec2_vpc_subnet - Manage subnets in AWS virtual private clouds
- ec2_vpc_subnet_facts - Gather facts about ec2 VPC subnets in AWS
- ec2_vpc_vgw - Create and delete AWS VPN Virtual Gateways.
- ec2_vpc_vgw_facts - Gather facts about virtual gateways in AWS
- ec2_vpc_vpn - Create, modify, and delete EC2 VPN connections.
- ec2_vpc_vpn_facts - Gather facts about VPN Connections in AWS.
- ec2_win_password - gets the default administrator password for ec2 windows instances
- ecs_attribute - manage ecs attributes
- ecs_cluster - create or terminate ecs clusters
- ecs_ecr - Manage Elastic Container Registry repositories
- ecs_service - create, terminate, start or stop a service in ecs
- ecs_service_facts - list or describe services in ecs
- ecs_task - run, start or stop a task in ecs
- ecs_taskdefinition - register a task definition in ecs
- ecs_taskdefinition_facts - describe a task definition in ecs
- efs - create and maintain EFS file systems
- efs_facts - Get information about Amazon EFS file systems
- elasticache - Manage cache clusters in Amazon Elasticache.
- elasticache_facts - Retrieve facts for AWS Elasticache clusters
- elasticache_parameter_group - Manage cache security groups in Amazon Elasticache.
- elasticache_snapshot - Manage cache snapshots in Amazon Elasticache.
- elasticache_subnet_group - manage Elasticache subnet groups
- elb_application_lb - Manage an Application load balancer
- elb_application_lb_facts - Gather facts about application ELBs in AWS
- elb_classic_lb - Creates or destroys Amazon ELB.
- elb_classic_lb_facts - Gather facts about EC2 Elastic Load Balancers in AWS
- elb_instance - De-registers or registers instances from EC2 ELBs
- elb_network_lb - Manage a Network Load Balancer
- elb_target - Manage a target in a target group
- elb_target_group - Manage a target group for an Application or Network load balancer
- elb_target_group_facts - Gather facts about ELB target groups in AWS
- execute_lambda - Execute an AWS Lambda function
- iam - Manage IAM users, groups, roles and keys
- iam_cert - Manage server certificates for use on ELBs and CloudFront
- iam_group - Manage AWS IAM groups
- iam_managed_policy - Manage User Managed IAM policies
- iam_mfa_device_facts - List the MFA (Multi-Factor Authentication) devices registered for a user
- iam_policy - Manage IAM policies for users, groups, and roles
- iam_role - Manage AWS IAM roles
- iam_role_facts - Gather information on IAM roles
- iam_server_certificate_facts - Retrieve the facts of a server certificate
- iam_user - Manage AWS IAM users
- kinesis_stream - Manage a Kinesis Stream.
- lambda - Manage AWS Lambda functions
- lambda_alias - Creates, updates or deletes AWS Lambda function aliases.
- lambda_event - Creates, updates or deletes AWS Lambda function event mappings.
- lambda_facts - Gathers AWS Lambda function details as Ansible facts
- lambda_policy - Creates, updates or deletes AWS Lambda policy statements.
- lightsail - Create or delete a virtual machine instance in AWS Lightsail
- rds - create, delete, or modify an Amazon rds instance
- rds_instance_facts - obtain facts about one or more RDS instances
- rds_param_group - manage RDS parameter groups
- rds_snapshot_facts - obtain facts about one or more RDS snapshots
- rds_subnet_group - manage RDS database subnet groups
- redshift - create, delete, or modify an Amazon Redshift instance
- redshift_facts - Gather facts about Redshift cluster(s)
- redshift_subnet_group - manage Redshift cluster subnet groups
- route53 - add or delete entries in Amazons Route53 DNS service
- route53_facts - Retrieves route53 details using AWS methods
- route53_health_check - add or delete health-checks in Amazons Route53 DNS service
- route53_zone - add or delete Route53 zones
- s3_bucket - Manage S3 buckets in AWS, Ceph, Walrus and FakeS3
- s3_lifecycle - Manage s3 bucket lifecycle rules in AWS
- s3_logging - Manage logging facility of an s3 bucket in AWS
- s3_sync - Efficiently upload multiple files to S3
- s3_website - Configure an s3 bucket as a website
- sns - Send Amazon Simple Notification Service (SNS) messages
- sns_topic - Manages AWS SNS topics and subscriptions
- sqs_queue - Creates or deletes AWS SQS queues.
- sts_assume_role - Assume a role using AWS Security Token Service and obtain temporary credentials
- sts_session_token - Obtain a session token from the AWS Security Token Service
Atomic
Azure
- azure - create or terminate a virtual machine in azure (D)
- azure_rm_acs - Manage an Azure Container Service Instance (ACS).
- azure_rm_aks - Manage a managed Azure Container Service (AKS) Instance.
- azure_rm_aks_facts - Get Azure Kubernetes Service facts.
- azure_rm_availabilityset - Manage Azure availability set.
- azure_rm_availabilityset_facts - Get availability set facts.
- azure_rm_containerinstance - Manage an Azure Container Instance.
- azure_rm_containerregistry - Manage an Azure Container Registry.
- azure_rm_deployment - Create or destroy Azure Resource Manager template deployments
- azure_rm_dnsrecordset - Create, delete and update DNS record sets and records.
- azure_rm_dnsrecordset_facts - Get DNS Record Set facts.
- azure_rm_dnszone - Manage Azure DNS zones.
- azure_rm_dnszone_facts - Get DNS zone facts.
- azure_rm_functionapp - Manage Azure Function Apps
- azure_rm_functionapp_facts - Get Azure Function App facts
- azure_rm_image - Manage Azure image.
- azure_rm_keyvault - Manage Key Vault instance.
- azure_rm_keyvaultkey - Use Azure KeyVault keys.
- azure_rm_keyvaultsecret - Use Azure KeyVault Secrets.
- azure_rm_loadbalancer - Manage Azure load balancers.
- azure_rm_loadbalancer_facts - Get load balancer facts.
- azure_rm_managed_disk - Manage Azure Manage Disks
- azure_rm_managed_disk_facts - Get managed disk facts.
- azure_rm_mysqldatabase - Manage MySQL Database instance.
- azure_rm_mysqlserver - Manage MySQL Server instance.
- azure_rm_networkinterface - Manage Azure network interfaces.
- azure_rm_networkinterface_facts - Get network interface facts.
- azure_rm_postgresqldatabase - Manage PostgreSQL Database instance.
- azure_rm_postgresqlserver - Manage PostgreSQL Server instance.
- azure_rm_publicipaddress - Manage Azure Public IP Addresses.
- azure_rm_publicipaddress_facts - Get public IP facts.
- azure_rm_resource - Create any Azure resource.
- azure_rm_resource_facts - Generic facts of Azure resources.
- azure_rm_resourcegroup - Manage Azure resource groups.
- azure_rm_resourcegroup_facts - Get resource group facts.
- azure_rm_securitygroup - Manage Azure network security groups.
- azure_rm_securitygroup_facts - Get security group facts.
- azure_rm_sqldatabase - Manage SQL Database instance.
- azure_rm_sqlserver - Manage SQL Server instance
- azure_rm_sqlserver_facts - Get SQL Server facts.
- azure_rm_storageaccount - Manage Azure storage accounts.
- azure_rm_storageaccount_facts - Get storage account facts.
- azure_rm_storageblob - Manage blob containers and blob objects.
- azure_rm_subnet - Manage Azure subnets.
- azure_rm_virtualmachine - Manage Azure virtual machines.
- azure_rm_virtualmachine_extension - Managed Azure Virtual Machine extension
- azure_rm_virtualmachine_scaleset - Manage Azure virtual machine scale sets.
- azure_rm_virtualmachine_scaleset_facts - Get Virtual Machine Scale Set facts
- azure_rm_virtualmachineimage_facts - Get virtual machine image facts.
- azure_rm_virtualnetwork - Manage Azure virtual networks.
- azure_rm_virtualnetwork_facts - Get virtual network facts.
Centurylink
- clc_aa_policy - Create or Delete Anti Affinity Policies at CenturyLink Cloud.
- clc_alert_policy - Create or Delete Alert Policies at CenturyLink Cloud.
- clc_blueprint_package - deploys a blue print package on a set of servers in CenturyLink Cloud.
- clc_firewall_policy - Create/delete/update firewall policies
- clc_group - Create/delete Server Groups at Centurylink Cloud
- clc_loadbalancer - Create, Delete shared loadbalancers in CenturyLink Cloud.
- clc_modify_server - modify servers in CenturyLink Cloud.
- clc_publicip - Add and Delete public ips on servers in CenturyLink Cloud.
- clc_server - Create, Delete, Start and Stop servers in CenturyLink Cloud.
- clc_server_snapshot - Create, Delete and Restore server snapshots in CenturyLink Cloud.
Cloudscale
Cloudstack
- cs_account - Manages accounts on Apache CloudStack based clouds.
- cs_affinitygroup - Manages affinity groups on Apache CloudStack based clouds.
- cs_cluster - Manages host clusters on Apache CloudStack based clouds.
- cs_configuration - Manages configuration on Apache CloudStack based clouds.
- cs_domain - Manages domains on Apache CloudStack based clouds.
- cs_facts - Gather facts on instances of Apache CloudStack based clouds.
- cs_firewall - Manages firewall rules on Apache CloudStack based clouds.
- cs_host - Manages hosts on Apache CloudStack based clouds.
- cs_instance - Manages instances and virtual machines on Apache CloudStack based clouds.
- cs_instance_facts - Gathering facts from the API of instances from Apache CloudStack based clouds.
- cs_instance_nic - Manages NICs of an instance on Apache CloudStack based clouds.
- cs_instance_nic_secondaryip - Manages secondary IPs of an instance on Apache CloudStack based clouds.
- cs_instancegroup - Manages instance groups on Apache CloudStack based clouds.
- cs_ip_address - Manages public IP address associations on Apache CloudStack based clouds.
- cs_iso - Manages ISO images on Apache CloudStack based clouds.
- cs_loadbalancer_rule - Manages load balancer rules on Apache CloudStack based clouds.
- cs_loadbalancer_rule_member - Manages load balancer rule members on Apache CloudStack based clouds.
- cs_network - Manages networks on Apache CloudStack based clouds.
- cs_network_acl - Manages network access control lists (ACL) on Apache CloudStack based clouds.
- cs_network_acl_rule - Manages network access control list (ACL) rules on Apache CloudStack based clouds.
- cs_network_offering - Manages network offerings on Apache CloudStack based clouds.
- cs_nic - Manages NICs and secondary IPs of an instance on Apache CloudStack based clouds (D)
- cs_pod - Manages pods on Apache CloudStack based clouds.
- cs_portforward - Manages port forwarding rules on Apache CloudStack based clouds.
- cs_project - Manages projects on Apache CloudStack based clouds.
- cs_region - Manages regions on Apache CloudStack based clouds.
- cs_resourcelimit - Manages resource limits on Apache CloudStack based clouds.
- cs_role - Manages user roles on Apache CloudStack based clouds.
- cs_role_permission - Manages role permissions on Apache CloudStack based clouds.
- cs_router - Manages routers on Apache CloudStack based clouds.
- cs_securitygroup - Manages security groups on Apache CloudStack based clouds.
- cs_securitygroup_rule - Manages security group rules on Apache CloudStack based clouds.
- cs_service_offering - Manages service offerings on Apache CloudStack based clouds.
- cs_snapshot_policy - Manages volume snapshot policies on Apache CloudStack based clouds.
- cs_sshkeypair - Manages SSH keys on Apache CloudStack based clouds.
- cs_staticnat - Manages static NATs on Apache CloudStack based clouds.
- cs_storage_pool - Manages Primary Storage Pools on Apache CloudStack based clouds.
- cs_template - Manages templates on Apache CloudStack based clouds.
- cs_user - Manages users on Apache CloudStack based clouds.
- cs_vmsnapshot - Manages VM snapshots on Apache CloudStack based clouds.
- cs_volume - Manages volumes on Apache CloudStack based clouds.
- cs_vpc - Manages VPCs on Apache CloudStack based clouds.
- cs_vpc_offering - Manages vpc offerings on Apache CloudStack based clouds.
- cs_vpn_connection - Manages site-to-site VPN connections on Apache CloudStack based clouds.
- cs_vpn_customer_gateway - Manages site-to-site VPN customer gateway configurations on Apache CloudStack based clouds.
- cs_vpn_gateway - Manages site-to-site VPN gateways on Apache CloudStack based clouds.
- cs_zone - Manages zones on Apache CloudStack based clouds.
- cs_zone_facts - Gathering facts of zones from Apache CloudStack based clouds.
Digital_Ocean
- digital_ocean - Create/delete a droplet/SSH_key in DigitalOcean
- digital_ocean_account_facts - Gather facts about DigitalOcean User account
- digital_ocean_block_storage - Create/destroy or attach/detach Block Storage volumes in DigitalOcean
- digital_ocean_certificate - Manage certificates in DigitalOcean.
- digital_ocean_certificate_facts - Gather facts about DigitalOcean certificates
- digital_ocean_domain - Create/delete a DNS record in DigitalOcean
- digital_ocean_domain_facts - Gather facts about DigitalOcean Domains
- digital_ocean_floating_ip - Manage DigitalOcean Floating IPs
- digital_ocean_floating_ip_facts - DigitalOcean Floating IPs facts
- digital_ocean_image_facts - Gather facts about DigitalOcean images
- digital_ocean_load_balancer_facts - Gather facts about DigitalOcean load balancers
- digital_ocean_region_facts - Gather facts about DigitalOcean regions
- digital_ocean_size_facts - Gather facts about DigitalOcean Droplet sizes
- digital_ocean_snapshot_facts - Gather facts about DigitalOcean Snapshot
- digital_ocean_sshkey - Manage DigitalOcean SSH keys
- digital_ocean_sshkey_facts - DigitalOcean SSH keys facts
- digital_ocean_tag - Create and remove tag(s) to DigitalOcean resource.
- digital_ocean_tag_facts - Gather facts about DigitalOcean tags
- digital_ocean_volume_facts - Gather facts about DigitalOcean volumes
Dimensiondata
Docker
- docker - manage docker containers (D)
- docker_container - manage docker containers
- docker_image - Manage docker images.
- docker_image_facts - Inspect docker images
- docker_login - Log into a Docker registry.
- docker_network - Manage Docker networks
- docker_secret - Manage docker secrets.
- docker_service - Manage docker services and containers.
- docker_volume - Manage Docker volumes
- gc_storage - This module manages objects/buckets in Google Cloud Storage.
- gcdns_record - Creates or removes resource records in Google Cloud DNS
- gcdns_zone - Creates or removes zones in Google Cloud DNS
- gce - create or terminate GCE instances
- gce_eip - Create or Destroy Global or Regional External IP addresses.
- gce_img - utilize GCE image resources
- gce_instance_template - create or destroy instance templates of Compute Engine of GCP.
- gce_labels - Create, Update or Destroy GCE Labels.
- gce_lb - create/destroy GCE load-balancer resources
- gce_mig - Create, Update or Destroy a Managed Instance Group (MIG).
- gce_net - create/destroy GCE networks and firewall rules
- gce_pd - utilize GCE persistent disk resources
- gce_snapshot - Create or destroy snapshots for GCE storage volumes
- gce_tag - add or remove tag(s) to/from GCE instances
- gcp_backend_service - Create or Destroy a Backend Service.
- gcp_compute_address - Creates a GCP Address
- gcp_compute_backend_bucket - Creates a GCP BackendBucket
- gcp_compute_backend_service - Creates a GCP BackendService
- gcp_compute_disk - Creates a GCP Disk
- gcp_compute_firewall - Creates a GCP Firewall
- gcp_compute_forwarding_rule - Creates a GCP ForwardingRule
- gcp_compute_global_address - Creates a GCP GlobalAddress
- gcp_compute_global_forwarding_rule - Creates a GCP GlobalForwardingRule
- gcp_compute_health_check - Creates a GCP HealthCheck
- gcp_compute_http_health_check - Creates a GCP HttpHealthCheck
- gcp_compute_https_health_check - Creates a GCP HttpsHealthCheck
- gcp_compute_image - Creates a GCP Image
- gcp_compute_instance - Creates a GCP Instance
- gcp_compute_instance_group - Creates a GCP InstanceGroup
- gcp_compute_instance_group_manager - Creates a GCP InstanceGroupManager
- gcp_compute_instance_template - Creates a GCP InstanceTemplate
- gcp_compute_network - Creates a GCP Network
- gcp_compute_route - Creates a GCP Route
- gcp_compute_ssl_certificate - Creates a GCP SslCertificate
- gcp_compute_subnetwork - Creates a GCP Subnetwork
- gcp_compute_target_http_proxy - Creates a GCP TargetHttpProxy
- gcp_compute_target_https_proxy - Creates a GCP TargetHttpsProxy
- gcp_compute_target_pool - Creates a GCP TargetPool
- gcp_compute_target_ssl_proxy - Creates a GCP TargetSslProxy
- gcp_compute_target_tcp_proxy - Creates a GCP TargetTcpProxy
- gcp_compute_url_map - Creates a GCP UrlMap
- gcp_container_cluster - Creates a GCP Cluster
- gcp_container_node_pool - Creates a GCP NodePool
- gcp_dns_managed_zone - Creates a GCP ManagedZone
- gcp_dns_resource_record_set - Creates a GCP ResourceRecordSet
- gcp_forwarding_rule - Create, Update or Destroy a Forwarding_Rule.
- gcp_healthcheck - Create, Update or Destroy a Healthcheck.
- gcp_pubsub_subscription - Creates a GCP Subscription
- gcp_pubsub_topic - Creates a GCP Topic
- gcp_storage_bucket - Creates a GCP Bucket
- gcp_storage_bucket_access_control - Creates a GCP BucketAccessControl
- gcp_target_proxy - Create, Update or Destroy a Target_Proxy.
- gcp_url_map - Create, Update or Destory a Url_Map.
- gcpubsub - Create and Delete Topics/Subscriptions, Publish and pull messages on PubSub
- gcpubsub_facts - List Topics/Subscriptions and Messages from Google PubSub.
- gcspanner - Create and Delete Instances/Databases on Spanner
Memset
Misc
- cloud_init_data_facts - Retrieve facts of cloud-init.
- helm - Manages Kubernetes packages with the Helm package manager
- ovirt - oVirt/RHEV platform management
- proxmox - management of instances in Proxmox VE cluster
- proxmox_kvm - Management of Qemu(KVM) Virtual Machines in Proxmox VE cluster.
- proxmox_template - management of OS templates in Proxmox VE cluster
- rhevm - RHEV/oVirt automation
- serverless - Manages a Serverless Framework project
- terraform - Manages a Terraform deployment (and plans)
- virt - Manages virtual machines supported by libvirt
- virt_net - Manage libvirt network configuration
- virt_pool - Manage libvirt storage pools
- xenserver_facts - get facts reported on xenserver
Oneandone
- oneandone_firewall_policy - Configure 1&1 firewall policy.
- oneandone_load_balancer - Configure 1&1 load balancer.
- oneandone_monitoring_policy - Configure 1&1 monitoring policy.
- oneandone_private_network - Configure 1&1 private networking.
- oneandone_public_ip - Configure 1&1 public IPs.
- oneandone_server - Create, destroy, start, stop, and reboot a 1&1 Host server.
Opennebula
Openstack
- os_auth - Retrieve an auth token
- os_client_config - Get OpenStack Client config
- os_flavor_facts - Retrieve facts about one or more flavors
- os_floating_ip - Add/Remove floating IP from an instance
- os_group - Manage OpenStack Identity Groups
- os_image - Add/Delete images from OpenStack Cloud
- os_image_facts - Retrieve facts about an image within OpenStack.
- os_ironic - Create/Delete Bare Metal Resources from OpenStack
- os_ironic_inspect - Explicitly triggers baremetal node introspection in ironic.
- os_ironic_node - Activate/Deactivate Bare Metal Resources from OpenStack
- os_keypair - Add/Delete a keypair from OpenStack
- os_keystone_domain - Manage OpenStack Identity Domains
- os_keystone_domain_facts - Retrieve facts about one or more OpenStack domains
- os_keystone_endpoint - Manage OpenStack Identity service endpoints
- os_keystone_role - Manage OpenStack Identity Roles
- os_keystone_service - Manage OpenStack Identity services
- os_network - Creates/removes networks from OpenStack
- os_networks_facts - Retrieve facts about one or more OpenStack networks.
- os_nova_flavor - Manage OpenStack compute flavors
- os_nova_host_aggregate - Manage OpenStack host aggregates
- os_object - Create or Delete objects and containers from OpenStack
- os_port - Add/Update/Delete ports from an OpenStack cloud.
- os_port_facts - Retrieve facts about ports within OpenStack.
- os_project - Manage OpenStack Projects
- os_project_access - Manage OpenStack compute flavors acceess
- os_project_facts - Retrieve facts about one or more OpenStack projects
- os_quota - Manage OpenStack Quotas
- os_recordset - Manage OpenStack DNS recordsets
- os_router - Create or delete routers from OpenStack
- os_security_group - Add/Delete security groups from an OpenStack cloud.
- os_security_group_rule - Add/Delete rule from an existing security group
- os_server - Create/Delete Compute Instances from OpenStack
- os_server_action - Perform actions on Compute Instances from OpenStack
- os_server_facts - Retrieve facts about one or more compute instances
- os_server_group - Manage OpenStack server groups
- os_server_metadata - Add/Update/Delete Metadata in Compute Instances from OpenStack
- os_server_volume - Attach/Detach Volumes from OpenStack VM’s
- os_stack - Add/Remove Heat Stack
- os_subnet - Add/Remove subnet to an OpenStack network
- os_subnets_facts - Retrieve facts about one or more OpenStack subnets.
- os_user - Manage OpenStack Identity Users
- os_user_facts - Retrieve facts about one or more OpenStack users
- os_user_group - Associate OpenStack Identity users and groups
- os_user_role - Associate OpenStack Identity users and roles
- os_volume - Create/Delete Cinder Volumes
- os_volume_snapshot - Create/Delete Cinder Volume Snapshots
- os_zone - Manage OpenStack DNS zones
Ovirt
- ovirt_affinity_group - Module to manage affinity groups in oVirt/RHV
- ovirt_affinity_label - Module to manage affinity labels in oVirt/RHV
- ovirt_affinity_label_facts - Retrieve facts about one or more oVirt/RHV affinity labels
- ovirt_api_facts - Retrieve facts about the oVirt/RHV API
- ovirt_auth - Module to manage authentication to oVirt/RHV
- ovirt_cluster - Module to manage clusters in oVirt/RHV
- ovirt_cluster_facts - Retrieve facts about one or more oVirt/RHV clusters
- ovirt_datacenter - Module to manage data centers in oVirt/RHV
- ovirt_datacenter_facts - Retrieve facts about one or more oVirt/RHV datacenters
- ovirt_disk - Module to manage Virtual Machine and floating disks in oVirt/RHV
- ovirt_disk_facts - Retrieve facts about one or more oVirt/RHV disks
- ovirt_external_provider - Module to manage external providers in oVirt/RHV
- ovirt_external_provider_facts - Retrieve facts about one or more oVirt/RHV external providers
- ovirt_group - Module to manage groups in oVirt/RHV
- ovirt_group_facts - Retrieve facts about one or more oVirt/RHV groups
- ovirt_host_networks - Module to manage host networks in oVirt/RHV
- ovirt_host_pm - Module to manage power management of hosts in oVirt/RHV
- ovirt_host_storage_facts - Retrieve facts about one or more oVirt/RHV HostStorages (applicable only for block storage)
- ovirt_hosts - Module to manage hosts in oVirt/RHV
- ovirt_hosts_facts - Retrieve facts about one or more oVirt/RHV hosts
- ovirt_mac_pools - Module to manage MAC pools in oVirt/RHV
- ovirt_networks - Module to manage logical networks in oVirt/RHV
- ovirt_networks_facts - Retrieve facts about one or more oVirt/RHV networks
- ovirt_nics - Module to manage network interfaces of Virtual Machines in oVirt/RHV
- ovirt_nics_facts - Retrieve facts about one or more oVirt/RHV virtual machine network interfaces
- ovirt_permissions - Module to manage permissions of users/groups in oVirt/RHV
- ovirt_permissions_facts - Retrieve facts about one or more oVirt/RHV permissions
- ovirt_quotas - Module to manage datacenter quotas in oVirt/RHV
- ovirt_quotas_facts - Retrieve facts about one or more oVirt/RHV quotas
- ovirt_scheduling_policies_facts - Retrieve facts about one or more oVirt scheduling policies
- ovirt_snapshots - Module to manage Virtual Machine Snapshots in oVirt/RHV
- ovirt_snapshots_facts - Retrieve facts about one or more oVirt/RHV virtual machine snapshots
- ovirt_storage_connections - Module to manage storage connections in oVirt
- ovirt_storage_domains - Module to manage storage domains in oVirt/RHV
- ovirt_storage_domains_facts - Retrieve facts about one or more oVirt/RHV storage domains
- ovirt_storage_templates_facts - Retrieve facts about one or more oVirt/RHV templates relate to a storage domain.
- ovirt_storage_vms_facts - Retrieve facts about one or more oVirt/RHV virtual machines relate to a storage domain.
- ovirt_tags - Module to manage tags in oVirt/RHV
- ovirt_tags_facts - Retrieve facts about one or more oVirt/RHV tags
- ovirt_templates - Module to manage virtual machine templates in oVirt/RHV
- ovirt_templates_facts - Retrieve facts about one or more oVirt/RHV templates
- ovirt_users - Module to manage users in oVirt/RHV
- ovirt_users_facts - Retrieve facts about one or more oVirt/RHV users
- ovirt_vmpools - Module to manage VM pools in oVirt/RHV
- ovirt_vmpools_facts - Retrieve facts about one or more oVirt/RHV vmpools
- ovirt_vms - Module to manage Virtual Machines in oVirt/RHV
- ovirt_vms_facts - Retrieve facts about one or more oVirt/RHV virtual machines
Packet
Profitbricks
- profitbricks - Create, destroy, start, stop, and reboot a ProfitBricks virtual machine.
- profitbricks_datacenter - Create or destroy a ProfitBricks Virtual Datacenter.
- profitbricks_nic - Create or Remove a NIC.
- profitbricks_volume - Create or destroy a volume.
- profitbricks_volume_attachments - Attach or detach a volume.
Rackspace
- rax - create / delete an instance in Rackspace Public Cloud
- rax_cbs - Manipulate Rackspace Cloud Block Storage Volumes
- rax_cbs_attachments - Manipulate Rackspace Cloud Block Storage Volume Attachments
- rax_cdb - create/delete or resize a Rackspace Cloud Databases instance
- rax_cdb_database - create / delete a database in the Cloud Databases
- rax_cdb_user - create / delete a Rackspace Cloud Database
- rax_clb - create / delete a load balancer in Rackspace Public Cloud
- rax_clb_nodes - add, modify and remove nodes from a Rackspace Cloud Load Balancer
- rax_clb_ssl - Manage SSL termination for a Rackspace Cloud Load Balancer.
- rax_dns - Manage domains on Rackspace Cloud DNS
- rax_dns_record - Manage DNS records on Rackspace Cloud DNS
- rax_facts - Gather facts for Rackspace Cloud Servers
- rax_files - Manipulate Rackspace Cloud Files Containers
- rax_files_objects - Upload, download, and delete objects in Rackspace Cloud Files
- rax_identity - Load Rackspace Cloud Identity
- rax_keypair - Create a keypair for use with Rackspace Cloud Servers
- rax_meta - Manipulate metadata for Rackspace Cloud Servers
- rax_mon_alarm - Create or delete a Rackspace Cloud Monitoring alarm.
- rax_mon_check - Create or delete a Rackspace Cloud Monitoring check for an existing entity.
- rax_mon_entity - Create or delete a Rackspace Cloud Monitoring entity
- rax_mon_notification - Create or delete a Rackspace Cloud Monitoring notification.
- rax_mon_notification_plan - Create or delete a Rackspace Cloud Monitoring notification plan.
- rax_network - create / delete an isolated network in Rackspace Public Cloud
- rax_queue - create / delete a queue in Rackspace Public Cloud
- rax_scaling_group - Manipulate Rackspace Cloud Autoscale Groups
- rax_scaling_policy - Manipulate Rackspace Cloud Autoscale Scaling Policy
Scaleway
Smartos
Univention
Vmware
- vca_fw - add remove firewall rules in a gateway in a vca
- vca_nat - add remove nat rules in a gateway in a vca
- vca_vapp - Manages vCloud Air vApp instances.
- vcenter_folder - Manage folders on given datacenter
- vcenter_license - Manage VMware vCenter license keys
- vmware_cfg_backup - Backup / Restore / Reset ESXi host configuration
- vmware_cluster - Manage VMware vSphere clusters
- vmware_cluster_facts - Gather facts about clusters available in given vCenter
- vmware_datacenter - Manage VMware vSphere Datacenters
- vmware_datastore_cluster - Manage VMware vSphere datastore clusters
- vmware_datastore_facts - Gather facts about datastores available in given vCenter
- vmware_datastore_maintenancemode - Place a datastore into maintenance mode
- vmware_dns_config - Manage VMware ESXi DNS Configuration
- vmware_drs_rule_facts - Gathers facts about DRS rule on the given cluster
- vmware_dvs_host - Add or remove a host from distributed virtual switch
- vmware_dvs_portgroup - Create or remove a Distributed vSwitch portgroup.
- vmware_dvswitch - Create or remove a distributed vSwitch
- vmware_guest - Manages virtual machines in vCenter
- vmware_guest_disk_facts - Gather facts about disks of given virtual machine
- vmware_guest_facts - Gather facts about a single VM
- vmware_guest_file_operation - Files operation in a VMware guest operating system without network
- vmware_guest_find - Find the folder path(s) for a virtual machine by name or UUID
- vmware_guest_powerstate - Manages power states of virtual machines in vCenter
- vmware_guest_snapshot - Manages virtual machines snapshots in vCenter
- vmware_guest_snapshot_facts - Gather facts about virtual machine’s snapshots in vCenter
- vmware_guest_tools_wait - Wait for VMware tools to become available
- vmware_host - Add / Remove ESXi host to / from vCenter
- vmware_host_acceptance - Manage acceptance level of ESXi host
- vmware_host_capability_facts - Gathers facts about an ESXi host’s capability information
- vmware_host_config_facts - Gathers facts about an ESXi host’s advance configuration information
- vmware_host_config_manager - Manage advance configurations about an ESXi host
- vmware_host_datastore - Manage a datastore on ESXi host
- vmware_host_dns_facts - Gathers facts about an ESXi host’s DNS configuration information
- vmware_host_facts - Gathers facts about remote ESXi hostsystem
- vmware_host_firewall_facts - Gathers facts about an ESXi host’s firewall configuration information
- vmware_host_firewall_manager - Manage firewall configurations about an ESXi host
- vmware_host_lockdown - Manage administrator permission for the local administrative account for the ESXi host
- vmware_host_ntp - Manage NTP configurations about an ESXi host
- vmware_host_package_facts - Gathers facts about available packages on an ESXi host
- vmware_host_powerstate - Manages power states of host systems in vCenter
- vmware_host_service_facts - Gathers facts about an ESXi host’s services
- vmware_host_service_manager - Manage services on a given ESXi host
- vmware_host_vmnic_facts - Gathers facts about vmnics available on the given ESXi host
- vmware_local_role_manager - Manage local roles on an ESXi host
- vmware_local_user_facts - Gather facts about users on the given ESXi host
- vmware_local_user_manager - Manage local users on an ESXi host
- vmware_maintenancemode - Place a host into maintenance mode
- vmware_migrate_vmk - Migrate a VMK interface from VSS to VDS
- vmware_portgroup - Create a VMware portgroup
- vmware_portgroup_facts - Gathers facts about an ESXi host’s portgroup configuration
- vmware_resource_pool - Add/remove resource pools to/from vCenter
- vmware_resource_pool_facts - Gathers facts about resource pool information
- vmware_tag - Manage VMware tags
- vmware_tag_facts - Manage VMware tag facts
- vmware_target_canonical_facts - Return canonical (NAA) from an ESXi host system
- vmware_vm_facts - Return basic facts pertaining to a vSphere virtual machine guest
- vmware_vm_shell - Run commands in a VMware guest operating system
- vmware_vm_vm_drs_rule - Configure VMware DRS Affinity rule for virtual machine in given cluster
- vmware_vm_vss_dvs_migrate - Migrates a virtual machine from a standard vswitch to distributed
- vmware_vmkernel - Manage a VMware VMkernel Interface aka. Virtual NICs of host system.
- vmware_vmkernel_facts - Gathers VMKernel facts about an ESXi host
- vmware_vmkernel_ip_config - Configure the VMkernel IP Address
- vmware_vmotion - Move a virtual machine using vMotion
- vmware_vsan_cluster - Configure VSAN clustering on an ESXi host
- vmware_vswitch - Manage a VMware Standard Switch to an ESXi host.
- vmware_vswitch_facts - Gathers facts about an ESXi host’s vswitch configurations
- vsphere_copy - Copy a file to a vCenter datastore
- vsphere_guest - Create/delete/manage a guest VM through VMware vSphere. (D)
Vultr
- vr_account_facts - Gather facts about the Vultr account.
- vr_dns_domain - Manages DNS domains on Vultr.
- vr_dns_record - Manages DNS records on Vultr.
- vr_firewall_group - Manages firewall groups on Vultr.
- vr_firewall_rule - Manages firewall rules on Vultr.
- vr_server - Manages virtual servers on Vultr.
- vr_ssh_key - Manages ssh keys on Vultr.
- vr_startup_script - Manages startup scripts on Vultr.
- vr_user - Manages users on Vultr.
Webfaction
- webfaction_app - Add or remove applications on a Webfaction host
- webfaction_db - Add or remove a database on Webfaction
- webfaction_domain - Add or remove domains and subdomains on Webfaction
- webfaction_mailbox - Add or remove mailboxes on Webfaction
- webfaction_site - Add or remove a website on a Webfaction host
f)Windows
- win_acl - Set file/directory/registry permissions for a system user or group
- win_acl_inheritance - Change ACL inheritance
- win_audit_policy_system - Used to make changes to the system wide Audit Policy.
- win_audit_rule - Adds an audit rule to files, folders, or registry keys
- win_certificate_store - Manages the certificate store
- win_chocolatey - Manage packages using chocolatey
- win_command - Executes a command on a remote Windows node
- win_copy - Copies files to remote locations on windows hosts
- win_defrag - Consolidate fragmented files on local volumes
- win_disk_facts - Show the attached disks and disk information of the target host
- win_disk_image - Manage ISO/VHD/VHDX mounts on Windows hosts
- win_dns_client - Configures DNS lookup on Windows hosts
- win_domain - Ensures the existence of a Windows domain.
- win_domain_controller - Manage domain controller/member server state for a Windows host
- win_domain_group - creates, modifies or removes domain groups
- win_domain_membership - Manage domain/workgroup membership for a Windows host
- win_domain_user - Manages Windows Active Directory user accounts
- win_dotnet_ngen - Runs ngen to recompile DLLs after .NET updates
- win_dsc - Invokes a PowerShell DSC configuration
- win_environment - Modify environment variables on windows hosts
- win_eventlog - Manage Windows event logs
- win_eventlog_entry - Write entries to Windows event logs
- win_feature - Installs and uninstalls Windows Features on Windows Server
- win_file - Creates, touches or removes files or directories.
- win_file_version - Get DLL or EXE file build version
- win_find - Return a list of files based on specific criteria
- win_firewall - Enable or disable the Windows Firewall
- win_firewall_rule - Windows firewall automation
- win_get_url - Downloads file from HTTP, HTTPS, or FTP to node
- win_group - Add and remove local groups
- win_group_membership - Manage Windows local group membership
- win_hotfix - install and uninstalls Windows hotfixes
- win_iis_virtualdirectory - Configures a virtual directory in IIS.
- win_iis_webapplication - Configures IIS web applications
- win_iis_webapppool - configures an IIS Web Application Pool
- win_iis_webbinding - Configures a IIS Web site binding.
- win_iis_website - Configures a IIS Web site.
- win_lineinfile - Ensure a particular line is in a file, or replace an existing line using a back-referenced regular expression.
- win_mapped_drive - maps a network drive for a user
- win_msg - Sends a message to logged in users on Windows hosts.
- win_msi - Installs and uninstalls Windows MSI files (D)
- win_nssm - NSSM - the Non-Sucking Service Manager
- win_owner - Set owner
- win_package - Installs/uninstalls an installable package
- win_pagefile - Query or change pagefile configuration
- win_path - Manage Windows path environment variables
- win_ping - A windows version of the classic ping module
- win_power_plan - Changes the power plan of a Windows system
- win_product_facts - Provides Windows product information (product id, product key)
- win_psexec - Runs commands (remotely) as another (privileged) user
- win_psmodule - Adds or removes a Powershell Module.
- win_rabbitmq_plugin - Manage RabbitMQ plugins
- win_reboot - Reboot a windows machine
- win_reg_stat - returns information about a Windows registry key or property of a key
- win_regedit - Add, change, or remove registry keys and values
- win_region - Set the region and format settings
- win_regmerge - Merges the contents of a registry file into the windows registry
- win_robocopy - Synchronizes the contents of two directories using Robocopy
- win_route - Add or remove a static route.
- win_say - Text to speech module for Windows to speak messages and optionally play sounds
- win_scheduled_task - Manage scheduled tasks
- win_scheduled_task_stat - Returns information about a Windows Scheduled Task
- win_security_policy - changes local security policy settings
- win_service - Manage and query Windows services
- win_share - Manage Windows shares
- win_shell - Execute shell commands on target hosts.
- win_shortcut - Manage shortcuts on Windows
- win_stat - returns information about a Windows file
- win_tempfile - Creates temporary files and directories.
- win_template - Templates a file out to a remote server.
- win_timezone - Sets Windows machine timezone
- win_toast - Sends Toast windows notification to logged in users on Windows 10 or later hosts
- win_unzip - Unzips compressed files and archives on the Windows node
- win_updates - Download and install Windows updates
- win_uri - Interacts with webservices
- win_user - Manages local Windows user accounts
- win_user_right - Manage Windows User Rights
- win_wait_for - Waits for a condition before continuing
- win_wakeonlan - Send a magic Wake-on-LAN (WoL) broadcast packet
- win_webpicmd - Installs packages using Web Platform Installer command-line
- win_whoami - Returns information about the current user and process
g) more..
7) Variables
-store information that varies with each host
a) in inventory
#Sample Inventory File
web ansible_host=server1.company.com
db ansible_host=server2.company.com ansible_connection=winrm
b) in playbook
#Sample Ansible Playbook1.yml
-
name: Add DNS server to resolv.conf
hosts: localhost
vars:
dns_server: 10.1.250.10
tasks:
- lineinfile:
path: /etc/resolv.conf
line: 'nameserver {{ dns_server }}'
c) in variable files
#Sample Variable_file.yml
variable1: value1
variable2: value2
Jinja2 templating
source: '{{ inter_ip_range }}'
8) Conditionals
#Sample Inventory File
web1 ansible_host=server1.company.com
db ansible_host=db.company.com ansible_connection=winrm
web2 ansible_host=server2.company.com
[all_servers]
web1
db
web2
#Sample Ansible Playbook1.yml
-
name: Start services hosts: localhost
hosts: all_servers
tasks:
-
service: name=mysql state=started
when: ansible_host == db.company.com
-
service: name=httpd state=started
when: ansible_host =='server1.company.com' or ansible_host =='server2.company.com'
#Sample Ansible Playbook1.yml
-
name: Check status of service and email if its down
hosts: localhost
tasks:
-
command: service httpd status
register: command_output
-
mail:
to: Admins <system.admins@company.com>
subject: Service Alert
body: 'Service {{ ansible_hostname }} is down.'
when: command_output.stdout.find('down') != -1
https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html
9) Loops
a) with_items
#Sample Ansible Playbook1.yml
-
name: Install Packages
hosts: localhost
tasks:
-
yum: name='{{ item }}' state=present
with_items:
- httpd
- binutils
- glibc
10) Roles
a) include
-include <playbook name>
b) include tasks and vars
tasks:
- include: tasks.yml
vars_files:
- variables.yml
roles:
-webservers
Ansible Project
inventory.txt.
setup_application.yml
roles
webservers
files
templates
tasks
handlers
vars
defaults
meta
defaults
meta
11) Preparing Windows Server
-Ansible Control Machine can only be Linux and not Windows
-Windows machines can be targets of Ansible and thus be part of automation
-Ansible connects to a windows machine using winrm
-Requirement:
*pywinrm module installed on the Ansible Control Machine - pip install "pywinrm>=0.2.2"
*Setup WinRM - examples/scripts/ConfigureRemotingForAnsible.ps1
*Different modes of authentication:
** Basic/Certificatwe/Kerberos/NTLM/CredSSP
12) Ansible-Galaxy
https://galaxy.ansible.com/
13) Patterns
hosts : localhost
-host1, host2, host3
-group1, host1
-host*
-*.company.com
https://docs.ansible.com/ansible/2.6/user_guide/intro_patterns.html
14) Dynamic Inventory
ansible-playbook -i inventory.txt playbook.yml
ansible-playbook -i inventory.py playbook.yml
15) Developing Custom Modules
https://docs.ansible.com/ansible/2.5/dev_guide/developing_modules.html
16)Web Application
1. Identify Server
2. Python
3. Install Configure Start
4. Install Flask
5. source Code
6. Run
https://github.com/mmumshad/simple-webapp
Simple Web Application
This is a simple web application using Python Flask and MySQL database. This is used in the demonstration of development of Ansible Playbooks.
Below are the steps required to get this working on a base linux system.
- Install all required dependencies
- Install and Configure Database
- Start Database Service
- Install and Configure Web Server
- Start Web Server
1. Install all required dependencies
Python and its dependencies
apt-get install -y python python-setuptools python-dev build-essential python-pip python-mysqldb
2. Install and Configure Database
Install MySQL database
apt-get install -y mysql-server mysql-client
3. Start Database Service
- Start the database service
service mysql start - Create database and database users
# mysql -u <username> -p mysql> CREATE DATABASE employee_db; mysql> GRANT ALL ON *.* to db_user@'%' IDENTIFIED BY 'Passw0rd'; mysql> USE employee_db; mysql> CREATE TABLE employees (name VARCHAR(20)); - Insert some test data
mysql> INSERT INTO employees VALUES ('JOHN');
4. Install and Configure Web Server
Install Python Flask dependency
pip install flask
pip install flask-mysql
- Copy app.py or download it from source repository
- Configure database credentials and parameters
5. Start Web Server
Start web server
FLASK_APP=app.py flask run --host=0.0.0.0
6. Test
Open a browser and go to URL
http://<IP>:5000 => Welcome
http://<IP>:5000/how%20are%20you => I am good, how about you?
http://<IP>:5000/read%20from%20database => JOHN
WebApp Installation Instructions for Centos 7
The installation procedure is a bit different on Centos 7. So those of you following this course from the first course, please follow the below instructions:
# Install Python Pip and dependencies on Centos 7
-------------------------------------------------
sudo yum install -y epel-release python python-pip
sudo pip install flask flask-mysql
# If you come across a certification validation error while running the above command, please use the below command.
# sudo pip install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org flask flask-mysql
# Install MySQL Server on Centos 7
---------------------------------------------
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum update
sudo yum -y install mysql-server
sudo service mysql start
# Inventory file
db_and_web_server1 ansible_ssh_pass=Passw0rd ansible_host=192.168.1.6
db_and_web_server2 ansible_ssh_pass=Passw0rd ansible_host=192.168.1.15
#Ansible Playbook
-
name: Deploy Web Application
hosts: db_and_web_server*
tasks:
- name: Install dependecies
apt: name={{ item }} state=installed
with_items:
- python-setuptools
- python-dev
- build-essential
- python-pip
- python-mysqldb
- name: Install MySQL database
apt: name={{ item }} state=installed
with_items:
- mysql-server
- mysql-client
- name: Start Mysql Service
service:
name: mysql
state: started
enabled: yes
- name: Create Application Database
mysql_db: name=employee_db state=present
- name: Create Application DB User
mysql_user:
name: db_user
password: Passw0rd
priv: '*.*:ALL'
state: present
host: '%'
- name: Install Python Flask dependencies
pip:
name: {{ item }}
state: present
with_items:
- flask
- flask-mysql
- name: Copy web-server code
copy: src=app.py dest=/opt/app.py
- name: Run web-server
shell FLASK_APP=/opt/app.py nohup flask run --host=0.0.0.0
#app.py
| import os | |
| from flask import Flask | |
| from flaskext.mysql import MySQL # For newer versions of flask-mysql | |
| # from flask.ext.mysql import MySQL # For older versions of flask-mysql | |
| app = Flask(__name__) | |
| mysql = MySQL() | |
| mysql_database_host = 'MYSQL_DATABASE_HOST' in os.environ and os.environ['MYSQL_DATABASE_HOST'] or 'localhost' | |
| # MySQL configurations | |
| app.config['MYSQL_DATABASE_USER'] = 'db_user' | |
| app.config['MYSQL_DATABASE_PASSWORD'] = 'Passw0rd' | |
| app.config['MYSQL_DATABASE_DB'] = 'employee_db' | |
| app.config['MYSQL_DATABASE_HOST'] = mysql_database_host | |
| mysql.init_app(app) | |
| conn = mysql.connect() | |
| cursor = conn.cursor() | |
| @app.route("/") | |
| def main(): | |
| return "Welcome!" | |
| @app.route('/how are you') | |
| def hello(): | |
| return 'I am good, how about you?' | |
| @app.route('/read from database') | |
| def read(): | |
| cursor.execute("SELECT * FROM employees") | |
| row = cursor.fetchone() | |
| result = [] | |
| while row is not None: | |
| result.append(row[0]) | |
| row = cursor.fetchone() | |
| return ",".join(result) | |
| if __name__ == "__main__": | |
| app.run() |
17) Asynchronous Actions
18) Error Handling
19) Jinja 2 Templating
20) Lookups
21) Vault
22) Dynamic Inventory
23) Custom Modules
24) Plugins
25) Practice
26) playable
sudo docker run -p 80:8080 mmumshad/ansible-playable
Komentarze
Prześlij komentarz