Difference between revisions of "Ansible"

From rbachwiki
Jump to navigation Jump to search
 
(38 intermediate revisions by the same user not shown)
Line 1: Line 1:
* Download and install Miniconda:
=[[Ansible Setup]]=
curl -OL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh


**You will be prompted several times during the installation process. Review the terms and conditions and select “yes” for each prompt.
=[[Ansible General Commands]]=
*Restart your shell session for the changes to your PATH to take effect.
=[[Ansible File Commands]]=
=[[Ansible User Commands]]=
=[[Ansible Ad-Hoc Commands]]=
=[[Ansible Roles]]=
'''Roles simplifies long playbooks by grouping tasks into smaller playbooks'''
=[[Ansible Roles by Application]]=
=[[Ansible Tags]]=
=[[Ansible Variables]]=
* Using Variables
* Get input from user (prompt)
=[[Ansible Handlers]]=
=[[Ansible Conditions]]=
=[[Ansible Vault]]=
=[[Ansible Management Tools]]=


exec bash -l
=[[Ansible Documentation]]=
 
*Create a new virtual environment for Ansible:
 
conda create -n ansible-dev python=3
*Activate the new environment:
 
conda activate ansible-dev
 
*Check your Python version:
 
python --version
 
'''Ubuntu 18.04'''
 
sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
 
*Verify that Ansible is installed:
 
ansible --version
 
==Configure Ansible==
'''By default, Ansible’s configuration file location is <code>/etc/ansible/ansible.cfg.</code> In most cases, the default configurations are enough to get you started using Ansible. In this example, you will use Ansible’s default configurations.'''
 
*To view a list of all current configs available to your control node, use the <code>ansible-config</code> command line utility.
 
ansible-config list
 
===Create an Ansible Inventory===
'''Ansible keeps track of its managed nodes using an inventory file located in <code>/etc/ansible/hosts. </code>In the inventory file, you can group your managed nodes and use these groups to target specific hosts that make up your infrastructure'''
 
*Add your nodes to the default inventory file.
 
<code>File: /etc/ansible/hosts</code>
[nginx]
203.0.113.0
[wordpress]
203.0.113.1
 
'''Each bracketed label denotes an Ansible group . Grouping your nodes by function will make it easier to run commands against the correct set of nodes.'''
 
<div style='padding:10px;background:yellow;'>
Note
The /etc/ansible directory will not exist by default in some environments. If you find that this is the case, create it manually with the following command:
 
mkdir /etc/ansible/
If you are using a non-standard SSH port on your nodes, include the port after a colon on the same line within your hosts file (203.0.113.1:2222).
<div>

Latest revision as of 14:47, 28 July 2022