Skip to content

How to setup Ansible control note

Pablo Suárez Hernández edited this page Jul 15, 2022 · 2 revisions

This guide describe how to setup an Ansible control node in a SLE15SP1 system.

Installation

Configuration

  • Create your inventory adding your hosts to be managed by Ansible. Default path for the Ansible inventory is /etc/ansible/hosts. This is an example:
my-ansible-managed-client-1.tf.local
my-ansible-managed-client-2.tf.local
my-ansible-managed-client-3.tf.local
my-ansible-managed-client-4.tf.local ansible_ssh_private_key_file=/etc/ansible/some_ssh_key

[mygroup1]
my-ansible-managed-client-1.tf.local
my-ansible-managed-client-2.tf.local

[mygroup2]
my-ansible-managed-client-3.tf.local

[all:vars]
ansible_ssh_private_key_file=/etc/ansible/my_ansible_private_key
  • Create the SSH keys that you're using in your inventory. Example:
# ssh-keygen -f /etc/ansible/my_ansible_private_key
  • Copy the generated SSH keys to the Ansible managed clients. Example:
# ssh-copy-id -i /etc/ansible/my_ansible_private_key [email protected]

Test that Ansible is working

  • Some examples:
# ansible all -m ping
# ansible mygroup1 -m ping
# ansible my-ansible-managed-client-1.tf.local -m ping

Necessary patches for Salt in the Ansible control node

(already integrated in Salt)

I'm pushing all necessary patches for Salt to an OBS branch: https://build.opensuse.org/package/show/home:PSuarezHernandez:branches:systemsmanagement:saltstack:products:next/salt

In order to have the expected functionality in Salt available in your SLE15SP1 system to be used as "Ansible control node", you need to:

  1. Add this repo to your SLE15SP1 Ansible control node instance: https://download.opensuse.org/repositories/home:/PSuarezHernandez:/branches:/systemsmanagement:/saltstack:/products:/next/SLE_15_SP1/
  2. Do zypper refresh and install Salt from this repository.
  3. Check if you can get the Ansible inventory with: salt-call --local ansible.targets

Getting some playbooks:

There are a bunch of playbooks examples at https://github.com/ansible/ansible-examples

  1. Install git-core and clone the above repo in your Ansible control node.
Clone this wiki locally