How generate dynamic host file with only IP of concrete vendor (by MAC)

19 views
Skip to first unread message

Michal Šiman

unread,
Apr 20, 2020, 5:56:07 AM4/20/20
to Ansible Project
Hello to everybody. I would like run ansible playbook on all RPi (raspberry) in our network (at this moment we have around 300 pieces). All RPi have a IP dynamic from DHCP server. My idea is scann complete network found all live IP, get MAC of IP, filter only MAC with RPi vendor and from this IP create a list, dynamic host file. I have ansible on Linux for shure. What you recomend for quick solution? Nmap? Ping by sh from python? I all ready tried some solution but is too slow and non comfortable ... maybe somebody solving similar problem in history. Thx

Dick Visser

unread,
Apr 20, 2020, 7:04:19 AM4/20/20
to ansible...@googlegroups.com
Take a look at https://docs.ansible.com/ansible/latest/plugins/inventory/nmap.html

On Mon, 20 Apr 2020 at 11:56, Michal Šiman <michal...@gmail.com> wrote:
>
> Hello to everybody. I would like run ansible playbook on all RPi (raspberry) in our network (at this moment we have around 300 pieces). All RPi have a IP dynamic from DHCP server. My idea is scann complete network found all live IP, get MAC of IP, filter only MAC with RPi vendor and from this IP create a list, dynamic host file. I have ansible on Linux for shure. What you recomend for quick solution? Nmap? Ping by sh from python? I all ready tried some solution but is too slow and non comfortable ... maybe somebody solving similar problem in history. Thx
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3bcd8201-71db-4d15-be49-1aa97a700a4d%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

David Foley

unread,
Apr 20, 2020, 7:33:08 AM4/20/20
to Ansible Project
I'm using the following Playbook, which is taken the IP Address Entered from the Jenkins Pipeline:

---
  - name: Running Appened To Ansible Host File Playbook
    hosts: localhost
    connection: local
    tasks:
    - name: Adding The IP Address of the Newly Created Server to Ansible Host File
      blockinfile:
        path: /etc/ansible/hosts
        block: |

          [win]
          "{{ ip }}"

          [win:vars]
          ansible_user="{{ service }}"
          ansible_password="{{ service_pass}}"
          ansible_connection=winrm
          ansible_winrm_transport=credssp
          ansible_winrm_server_cert_validation=ignore

Reply all
Reply to author
Forward
0 new messages