filmov
tv
Ansible: Using Ansible Galaxy to extend functionality
Показать описание
In this video I'll be installing MongoDB via Ansible Galaxy collection.
Ansible Galaxy is a repository of Ansible content which expands on what is available in Ansible.
This includes roles, modules, and plugins.
Roles: groupings of related content. Think of complex playbooks broken into separate files.
Modules: individual items of functionality (a module to ping, or a module to gather info on a server)
Plugins: code that extends the functionality of Ansible itself. For example, a 'lookup' plugin to to gather data from MongoDB (or any other database) and have this info able to be used in a playbook via Jinja templating - as you would with Ansible facts, ex:
{{ hostvars[host]['ansible_facts']['eth0']['ipv4']['address'] }}
Install MongoDB collection:
Playbook:
---
- name: Install MongoDB via Ansible Galaxy Community Role
hosts: mongo
become: true
roles:
- mongodb_repository
- mongodb_install
...
Error on initial playbook run:
ERROR! the role 'mongodb_repository' was not found in /tmp/awx_191_uasnv_n6/project/roles:/tmp/awx_191_uasnv_n6/requirements_roles:/var/lib/awx/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/tmp/awx_191_uasnv_n6/project
It appears the Ansible Galaxy files were installed to a different location than what was being looked for.
# cp --recursive /home/admin/.ansible/collections/ansible_collections/community/mongodb/roles/* .
After this the roles and MongoDB install worked.
Keep in mind that the Mongod service was not started or enabled.
Just a reminder to be aware of what the role is going to do, and not assume what it will do.
For example, it also installed MongoDB version 4.2.14, not 4.4.6 which is the newest release version.
Ansible Galaxy is a repository of Ansible content which expands on what is available in Ansible.
This includes roles, modules, and plugins.
Roles: groupings of related content. Think of complex playbooks broken into separate files.
Modules: individual items of functionality (a module to ping, or a module to gather info on a server)
Plugins: code that extends the functionality of Ansible itself. For example, a 'lookup' plugin to to gather data from MongoDB (or any other database) and have this info able to be used in a playbook via Jinja templating - as you would with Ansible facts, ex:
{{ hostvars[host]['ansible_facts']['eth0']['ipv4']['address'] }}
Install MongoDB collection:
Playbook:
---
- name: Install MongoDB via Ansible Galaxy Community Role
hosts: mongo
become: true
roles:
- mongodb_repository
- mongodb_install
...
Error on initial playbook run:
ERROR! the role 'mongodb_repository' was not found in /tmp/awx_191_uasnv_n6/project/roles:/tmp/awx_191_uasnv_n6/requirements_roles:/var/lib/awx/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/tmp/awx_191_uasnv_n6/project
It appears the Ansible Galaxy files were installed to a different location than what was being looked for.
# cp --recursive /home/admin/.ansible/collections/ansible_collections/community/mongodb/roles/* .
After this the roles and MongoDB install worked.
Keep in mind that the Mongod service was not started or enabled.
Just a reminder to be aware of what the role is going to do, and not assume what it will do.
For example, it also installed MongoDB version 4.2.14, not 4.4.6 which is the newest release version.