我正在尝试使用Ansible从Ansible列表中删除文件。我想遍历这个列表并删除以每个元素中存储的字符串开头的文件。我现在拥有的是:
---
- hosts: localhost
connection: local
vars:
regexp: '(?<=\/)(.*?)(?=\-[0-9])'
empty: [null]
tasks:
# Select only the part of each file path in the list that I need (the beginning).
- set_fact
我是一个为虚拟主机编写模板文件的人,文件中的DNS应该随环境主机名的不同而改变。下面是我试图解决的问题:
server {
listen 80;
charset utf-8;
server_name "{{ 'a.com if ansible_hostname='p.com' 'b.com' if ansible_hostname= 'd.com' 'z.com' if ansible hostname is 'k.com' else 'default.com