Simplify handling of localhost in inventory

This commit is contained in:
Ray Miller 2025-07-06 15:00:16 +01:00
parent 93c5cad460
commit 69f50fbadb
Signed by: ray
GPG key ID: 043F786C4CD681B8

View file

@ -51,7 +51,8 @@ this program. If not, see <https://www.gnu.org/licenses/>.
(eval-string (call-with-input-file filename get-string-all)
#:file filename)
(when (null? *inventory*)
(log-msg 'NOTICE "Inventory is empty, only localhost will be available")))
(log-msg 'NOTICE "Inventory is empty, only localhost will be available")
(defhost "localhost" #:connection (local-connection))))
(define (tagged-every? wanted-tags)
(lambda (h)
@ -67,8 +68,6 @@ this program. If not, see <https://www.gnu.org/licenses/>.
(define-method (resolve-hosts expr)
(match expr
("localhost" (list (or (find (named? "localhost") *inventory*)
(make <host> #:name "localhost" #:connection (local-connection)))))
((? string? hostname) (filter (named? hostname) *inventory*))
('all *inventory*)
(('tagged tag) (filter (tagged-every? (list tag)) *inventory*))