Back Home

Ansible

Ansible primarily runs in push mode using SSH, but you can also run Ansible using ansible-pull, where you can install Ansible on each agent, download the playbooks locally, and run them on individual machines.

Deployments are made over ssh, To speed up default SSH connections, you can always enable ControlPersist and the pipeline mode, which makes Ansible faster and secure.

Installation

On linux:

sudo apt install ansible 

Working with Virtual Machines, Remote Machines, Docker

Working with virutal machines, install:

$ sudo apt install virt-manager 
$ sudo apt install qemu-kvm libvirt-bin 

Getting Started - Inventory

The default Ansible inventory file is named hosts and placed in /etc/ansible. Machines can be configured into groups to allow many machines to be controlled at one

[webservers] 
site01 
site02 
site01-dr 
  
[production] 
site01 
site02 
db01 
bastion 

Ansible includes a simple module called ping that lets you test connectivity between yourself and the host.

To start locally add

[local]
localhost

and then call the in built ping command that will

  • attempt to ssh to the machine
  • return a ping response
 
ansible local -u richard -k -m ping 

You may get a json response

localhost | FAILED! => {
    "failed": true, 
    "msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"
}

you may need to also install (apt install openssh-server) to have ssh running and test the connetion Once all the dependencies are present then you will get

localhost | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

Configuration and Removing the Password prompt

ask_pass=True line in ansible.cfg file. I added a new group variables section for the whole inventory, it can be added for a specific group though.

[all:vars]
ansible_user=<username>
ansible_ssh_pass=<ssh_pass>

Ansible built in actions

  • uri for posting

Playbooks

Misc Deploy Mule using Cloudhub Api

using https://docs.mulesoft.com/runtime-manager/cloudhub-api

POST https://anypoint.mulesoft.com/cloudhub/api/applications/hello/deploy

CI/CD integration

 
puppet_chef_saltstack_and_ansible.txt · Last modified: 2019/09/10 10:24 by root
 
RSS - 200 © CrosswireDigitialMedia Ltd