Thanks to all of you.

foreman_expire_hosts <https://github.com/theforeman/foreman_expire_hosts>  
looks like to be what I am looking for except I can't succeed to add the 
"expire date" on table host (I am running a foreman 11.1 and the purposed 
method looks doens't regognize the VERSION variable). 

The solution of Martin looks OK for me.

Thanks.
Jon


On Tuesday, November 14, 2017 at 9:08:44 AM UTC+1, Martin Bačovský wrote:
>
> I'll just add that you can do either
>
> $ hammer --csv host list --search 'name ~ "gce*" and last_report > "2 days 
> ago"'
>
> or
>
> $ hammer --csv host list --search 'hostgroup = "gce" and last_report > "2 
> days ago"'
>
> to get the list to iterate over. The --search argument is using same 
> syntax as the search field in hosts UI.
>
> Martin 
>
> On Mon, Nov 13, 2017 at 3:01 PM, Neil Hanlon <[email protected] 
> <javascript:>> wrote:
>
>> Greg ++ as always with the save :)
>>
>> On Mon, Nov 13, 2017 at 8:59 AM Greg Sutcliffe <[email protected] 
>> <javascript:>> wrote:
>>
>>> You could even use hammer with one of the output formatters, and loop
>>> over it.
>>>
>>> Something like "hammer --csv host list --hostgroup GCE" would get you
>>> the starting list of hosts to loop, then a call to this API (don't think
>>> hammer has last-report):
>>>
>>> '/api/v2/hosts/<host-fqdn>/reports/last' | json_pp | grep "reported_at"
>>>
>>> would give you the last report date. You could compare those to $now and
>>> then call "hammer host delete --name <host-fqdn>" if it's too old.
>>>
>>> *OR* consider using the expire_hosts plugin, which if you're just
>>> concerned about cleanin up old hosts, might be exactly what you want.
>>> See https://github.com/theforeman/foreman_expire_hosts
>>>
>>> Greg
>>>
>>> --
>>> You received this message because you are subscribed to the Google 
>>> Groups "Foreman users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected] <javascript:>.
>>> To post to this group, send email to [email protected] 
>>> <javascript:>.
>>> Visit this group at https://groups.google.com/group/foreman-users.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Foreman users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/foreman-users.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to