[LINUX] Introduction to Ansible Part ③'Inventory'

inventory

A file for managing the server you are working on. Ansible automatically adds localhost to your inventory by default, so Connect directly to localhost without making an SSH connection.

Behavior type parameters

The default value can be overridden with [default] in the ansible.cfg file. ansible_ssh_host ** default: host name ** Host name / IP address to connect to SSH ansible_ssh_port default: 22 Port to connect to SSH ansible_ssh_user default: root SSH user ansible_ssh_pass ** default: none ** Password used for SSH authentication ansible_connection default: smart How Ansible connects to the host ansible_ssh_private_key_file ** default: none ** Private key used for SSH authentication ansible_shell_type default: sh Shell used to execute commands Besides, csh, fish, powershell can be used. (I don't use it much) ansible_python_interpreter default: /usr/bin/python Python interpreter on host Since the Ansible module is implemented in Python2, If the remote host Python2 interpreter is not in / usr / bin / python You need to change this value. ansible_*_interpreter ** default: none ** Interpreter settings for other languages

group

ansible automatically for all hosts in the all (or *) inventory Tasks are executed, but it is also possible to divide them into groups and execute tasks as shown below.

inventory



[target1]
host1
host2
host3

[target2]
host4
host5

It is also possible to create a group of groups as shown below.

inventory


[all host]
target1
target2

Add hosts and groups when running playbook

Ansible can add hosts and groups to the inventory while the playbook is running. add_host Add the host to the inventory. It can be used, for example, when using Ansible to provision a new virtual machine instance in the Iaas type cloud. group_by You can create a new group while the playbook is running.


** Related materials ** Introduction to Ansible (1)'Hello World' Introduction to Ansible Part 2'Basic Grammar'


** References ** First Ansible (written by Lorin Hochstein, translated by Ryuji Tamagawa, O'Reilly Japan Co., Ltd.)

Recommended Posts

Introduction to Ansible Part ③'Inventory'
Introduction to Ansible Part ④'Variable'
Introduction to Ansible Part 1'Hello World !!'
Introduction to Python Hands On Part 1
Introduction to MQTT (Introduction)
Introduction to Scrapy (1)
Introduction to Scrapy (3)
Introduction to Supervisor
Introduction to Tkinter 1: Introduction
Introduction to PyQt
Introduction to Scrapy (2)
[Linux] Introduction to Linux
Introduction to Scrapy (4)
Introduction to discord.py (2)
Introduction to discord.py
Kaggle: Introduction to Manual Feature Engineering Part 1
[Introduction to cx_Oracle] (Part 3) Basics of Table Reference
[Introduction to cx_Oracle] (Part 7) Handling of bind variables
Introduction to Web Scraping
Introduction to Nonparametric Bayes
Introduction to Python language
Introduction to TensorFlow-Image Recognition
Introduction to OpenCV (python)-(2)
Introduction to Dependency Injection
Introduction to Private Chainer
Introduction to machine learning
[Introduction to cx_Oracle] (Part 11) Basics of PL / SQL Execution
[Introduction to cx_Oracle] (Part 13) Connection using connection pool (client side)
Introduction to Python numpy pandas matplotlib (~ towards B3 ~ part2)
AOJ Introduction to Programming Topic # 1, Topic # 2, Topic # 3, Topic # 4
Introduction to electronic paper modules
A quick introduction to pytest-mock
Introduction to dictionary lookup algorithm
[Introduction to cx_Oracle] (Part 6) DB and Python data type mapping
[Learning memorandum] Introduction to vim
Introduction to PyTorch (1) Automatic differentiation
opencv-python Introduction to image processing
Introduction to Python Django (2) Win
Kubernetes Scheduler Introduction to Homebrew
An introduction to machine learning
[Introduction to cx_Oracle] Overview of cx_Oracle
Part 1 Attempt to code mathematics (∈)
[Introduction to pytorch-lightning] First Lit ♬
[Introduction to cx_Oracle] (Part 4) Fetch and scroll of result set
Introduction to Anomaly Detection 1 Basics
[Introduction to Systre] Fibonacci Retracement ♬
Introduction to Nonlinear Optimization (I)
An introduction to Python that even monkeys can understand (Part 3)
AOJ Introduction to Programming Topic # 5, Topic # 6
Introduction to Deep Learning ~ Learning Rules ~
[Introduction to Python] <list> [edit: 2020/02/22]
Machine learning to learn with Nogizaka46 and Keyakizaka46 Part 1 Introduction
Introduction to Python (Python version APG4b)
An introduction to Python Programming
Introduction to Python scikit-learn, matplotlib, single-layer algorithm (~ towards B3 ~ part3)
[Introduction to cx_Oracle] (8th) cx_Oracle 8.0 release
An introduction to Bayesian optimization
Deep Reinforcement Learning 1 Introduction to Reinforcement Learning
An introduction to Python that even monkeys can understand (Part 1)
Super introduction to machine learning
Series: Introduction to cx_Oracle Contents