How it is possible to integreat a netzwork switch in Foreman

I would like to integrate a few switches in Foreman in order to use the Ansible plugin to perform automatic and scheduled backups.
Since you have to specify operating systems and the like in Foreman to add hosts, my question is it is even possible to integreat a Switch and how exactly?

Foreman and Proxy versions:
Foreman Version 2.3, Ansible and Ansible Plug-in Newset

Distribution and version:
Ubunto 18.04

The question is, what exactly you want to achieve. Do you want to configure switches by using Ansible triggered from the Foreman? That is doable for sure. The only requirement is the switch runs sshd. You can create any operating system, it does not have to be fully supported (e.g. having a recognizable icon or having a known OS family). You don’t even have to specify the OS for running Ansible on that host. If you create it as unmanaged, OS will be created/udpated during the Ansible run.

I highly recommend reading the following blog posts for an introduction, it will explain some of the basic concepts necessary here

Hope this helps

1 Like

I want to Backup the running config of an Dell switch with ansible-playbook. With Foreman i want to schedule the Ansible-playbook, to execute it one times a day. What is the best way to do that? Should i try to integreate the Switch in Foreman and do a Ansible-Playbook as job-template? or what would be the besty way?

Yes, that’s how I’d do it. Create the switch as unmanaged host (registration, API, REX, whatever method works for you) and then setup repeated REX job (using ansible-playbook as a template). If you find recurring logic UI too esoteric, you can achieve the same with cron calling REX API or starting the job through hammer CLI.

1 Like

Perfekt Thanks. I´ll try it this way.

Would it make it a differnce if i create the host over the hammer cli oder over the Web interface of Foreman?

No, hammer is using the API in the same fashion the Web interface does, so it only a differs if you use different values.


I integreated a Switch as unmanged host. But it is a Switch from Dell. So i need the os6 Collcetion for that to do something with ansbile. This Collections needs some variables which normaly are in the ansible inventory file. How do i managed it, that foreman uses this inventory or how can i match the vars in Foreman, that foreman uses them. This is my Playbook:

  • hosts: all
    gather_facts: yes


    • name: backup

      backup: yes
      dir_path: /home/{{ inventory_hostname }}

the vars which needed are:

So first, install the os6 collection to your Foreman Proxy, then import all roles. It will also create ansible variables for them if they are listed in defaults/main.yml. You can define additional ones. Then assign the ansible role to your host and set ansible variable matchers for it’s fqdn. Then click run ansible button on the host detail page.

You could also create a job template that uses those roles, the inventory is always based on ansible variables, host parameters and potentially job inputs. (sorry for late answer, you probably already figured)