Installation#
$ dnf install ansible
Configuration#
The main configuration is stored in /etc/ansible/ansible.cfg, for example.
#inventory = /etc/ansible/hosts
#inventory_plugins = /usr/share/ansible/plugins/inventory
[inventory]
#enable_plugins = host_list, virtualbox, yaml, constructed
Inventory#
The inventory configuration is stored in /etc/ansible/hosts, for example:
[local]
127.0.0.1
[containers]
container ansible_connection=docker
To test the connection to the machines:
$ ansible -i hosts containers -m ping
Docker machines can be configured in docker_machine.yml, for example:
plugin: community.docker.docker_machine
strict: no
keyed_groups:
- separator: ''
key: docker_machine_node_attributes.DriverName
strict: no
keyed_groups:
- prefix: tag
key: 'dm_tags'
compose:
ansible_ssh_common_args: '"-o StrictHostKeyChecking=accept-new"'
See also:
Tasks#
To run a task:
$ ansible -i hosts local -m ping
Playbooks#
Create a playbook file (e.g. playbook.yml):
- hosts: local
tasks:
- name: Ping
ping:
To run the playbook:
$ ansible-playbook -i hosts playbook.yml
Platform-specific Notes#
On RHEL 8, all ansible-playbook commands will need to specify the following variable:
-e ansible_python_interpreter=/usr/libexec/platform-python
Docker#
$ ansible-galaxy collection install community.docke
See also:
Examples#
To run the script:
$ ansible-playbook -i hosts ansible-vms/pki-server.yml
Roles are defined in cipherboy/ansible-vms. See also:
tasks/main.yml
vars/main.yml
files/*