Skip to main content

Posts

Showing posts from February, 2020

Push logs and data into elasticsearch - Part 3 enrich your data with geoip

So if you are saving data in elastic search and this data contains IP Addresses, you might want to consider enriching your data with GeoIP. I'll take my router logging data (see part 2) and enrich them with GeoIP data. First of all, let's adjust the Index Template and add the GeoIP Longitude, Latitude and Location fields. I'll push the index template using the dev tools in Kibana. PUT _template/mikrotik-log { "index_patterns" : [ "mikrotik-log-*" ], "settings" : { "index" : { "codec" : "best_compression", "refresh_interval" : "5s", "number_of_shards" : "1", "number_of_replicas" : "1" } }, "mappings" : { "numeric_detection" : true, "dynamic_templates" : [ { "string_fields" : { "mapping" :...

Ansible - Conditional loop based on single item's state

I've had to deal with a little bit of automation for foreman / satellite in which we created hosts and also set them up for building them (build: true). Everything works for new hosts but there's a small problem for already existing hosts. With that 'build: true' a new build token will be generated and at the next reboot, hosts would be kickstarted using pxe. The solution is simple, get the changed state of every item in the loop and if 'changed' == true, then build the host. Turns out it was a bit more complicated than I expected since the state of the task will be changed if one item in it is different. Please note that I will be defining all variables in environment-specific inventories. So here's my solution to conditionally build hosts depending if their state in managing them was changed or not. Also, check the indentation before running this. --- - name: Manage foreman hosts hosts: foreman gather_facts: false tasks: ...