Table of Contents
-
Installed Ansible
-
Installed Ansible Runner
-
Running machine that can be connected to via SSH (key authentication is best)
Download foreman_ansible plugin
git clone https://github.com/theforeman/foreman_ansible.git
Enable foreman_ansible
plugin
# bundler.d/ansible.local.rb
gem 'foreman_ansible', path: '/path/to/foreman_ansible'
Install plugin dependencies & migrate database
bundle install
npm install
bundle exec rails db:migrate
Add plugin gems
# /path/to/smart-proxy/bundler.d/ansible.local.rb
gem 'smart_proxy_ansible', git: 'https://github.com/theforeman/smart_proxy_ansible.git'
Install gems
bundle install
Enable feature
# config/settings.d/ansible.yml
# See https://github.com/theforeman/smart_proxy_ansible/blob/master/settings.d/ansible.yml.example
# all configuration options
---
:enabled: true
Set path to ansible-runner-environment
export SMART_PROXY_ANSIBLE_ENVIRONMENT_WRAPPER="/path/to/smart_proxy_ansible/bin/ansible-runner-environment.sh"
Run all services
# In Foreman folder
bundle exec foreman start
bundle exec rake dynflow:executor
# In Smart Proxy folder
bundle exec bin/smart-proxy
# => [I] Successfully initialized 'ansible'
theforeman.foreman
collection contains Ansible Modules to manage Foreman and Katello installations.
Install Foreman Collection
ansible-galaxy collection install theforeman.foreman
Copy the default configuration to user’s HOME
cp /etc/ansible/ansible.cfg ~/.ansible.cfg
Add theforeman.foreman.foreman callback plugin to a callback plugin whitelist
ansible -i ,localhost -c local -m ini_file -a 'path=~/.ansible.cfg state=present section=defaults option=callback_whitelist value=theforeman.foreman.foreman' localhost
ansible -i ,localhost -c local -m ini_file -a 'path=~/.ansible.cfg state=present section=callback_foreman option=url value=http://localhost:3000' localhost
Create simple playbook ping_playbook.yml
---
- name: Ping Playbook
hosts: all
become: yes
become_user: root
gather_facts: true
tasks:
- name: Show host's hostname
debug:
msg: "{{ ansible_ssh_host }}"
And run it against the host from prerequisities
ansible-playbook -i,<domain-of-the-host-you-want-to-register> -u root -k ping_playbook.yml
Check that callback works and host has been created in the Foreman