#!/usr/bin/perl use strict; my $BASE_URL="tower2.thezengarden.net"; my $AAP_INVENTORY=14; my $CONTENT_TYPE="Content-type: application/json"; my $TOWER_TOKEN="Authorization: Bearer YtLStVtkMGKxnWinslNiqDgYwZqKfM"; my $csv = $ARGV[0]; open (CSV, "< $csv") or die "unable to read $csv: $0\n"; while (my $line = ) { chomp $line; $line =~ s/\r//g; my @host = split(/,/, $line); next if $host[1] =~ /Not/; my $json_args = "{\"name\": \"$host[1]\", \"description\": \"$host[0]\"}"; print "$json_args\n"; my $add_host_post = `curl -s -k -H \"$TOWER_TOKEN\" -H \"$CONTENT_TYPE\" -X POST -d '$json_args' \"https://$BASE_URL/api/v2/inventories/$AAP_INVENTORY/hosts/\"`; print "$add_host_post\n"; }