我的剧本中有以下变量:
SELECT tblDropDownItems.TaskID, tblDropDownItems.TaskName
FROM
(SELECT 0 AS TaskID, 'Installation' AS TaskName, 'B' AS ItemType
UNION
SELECT 1 AS TaskID, 'Setup' AS TaskName, 'B' AS ItemType
UNION
SELECT 2 AS TaskID, 'Feedback' AS TaskName, 'B' AS ItemType
UNION
SELECT 3 AS TaskID, 'Customer' AS TaskName, 'B' AS ItemType
UNION
SELECT 4 AS TaskID, 'Production' AS TaskName, 'P' AS ItemType
UNION
SELECT 5 AS TaskID, 'Debug' AS TaskName, 'P' AS ItemType
UNION
SELECT 6 AS TaskID, 'Review' AS TaskName, 'P' AS ItemType
UNION
SELECT 7 AS TaskID, 'Network' AS TaskName, 'P' AS ItemType
UNION
. . . your select clause for 'S' ItemType
UNION
. . . your select clause for 'O' ItemType) tblDropDownItems
INNER JOIN
(SELECT ItemType
FROM TblItem
WHERE ItemID = [ItemID]) tblItemType
ON tblDropDownItems.ItemType = tblItemType.ItemType
我需要能够通过Ansible剧本步骤在文件中写入以下内容:
frontends:
- domain01.fr
- domain02.fr
- domain03.fr
- domain04.fr
我想出了以下解决方案,但我对此不满意。
tcp://domain01.fr:11211,tcp://domain02.fr:11211,tcp://domain03.fr:11211,tcp://domain04.fr:11211
我无法在- name: Setting up Apache (2/2)
lineinfile:
path: /etc/opt/rh/rh-php56/php.ini
regexp: '^session.save_path ='
line: "session.save_path = 'tcp://{{ frontends | join(':11211,tcp://') }}'"
方法内部硬写域,因为它依赖很多,而且在某些情况下我只有2个域而不是4个域。
是否可能会有类似以下的内容:
lineinfile
提前谢谢
答案 0 :(得分:1)
是的。这是可能的。下面的 line
regexp: '^session.save_path ='
line: >-
session.save_path ={% for frontend in frontends %}
tcp://{{ frontend }}:11211{% if not loop.last %},{% endif %}{% endfor %}
给予
session.save_path = tcp://domain01.fr:11211, tcp://domain02.fr:11211, tcp://domain03.fr:11211, tcp://domain04.fr:11211