union(services) }}): can only concatenate list (not \"dict\") to list"

问题描述 投票:0回答:1
Is there any other way to stop and disable a list of services only if they are installed.

- name: Include variables for Amazon Linux.
  include_vars: ../vars/test.yml

- name: populate service facts
  service_facts:

- name: start the service if it's enabled
  service:
    name: "{{ item }}"
    enabled: no
    state: stopped
  loop: "{{ stop_services |union(services) }}"
  when: stop_services is defined

I'm trying to stop and disable a list of services only if they are installed. I'm calling the service_facts module to generate a list of running services and using filter "union" - name: Include ...

Your problem is described accurately by the error message:

is a list, and
ansible ansible-2.x
1个回答
1
投票

stop_services我试图只在安装了服务的情况下停止和禁用服务列表。我调用service_facts模块来生成正在运行的服务列表,并使用 "union "过滤器。services我得到一个错误

在({{ stop_services)上发生了意外的模板类型错误。

© www.soinside.com 2019 - 2024. All rights reserved.