如果我在剧本中定义了多个任务,ansible 是否会为每个任务创建一个单独的 ssh 连接。如果是,那不是性能问题。
因为每当我在运行剧本时执行冗长的 o/p 时,我都会针对每项任务发现这一点。“为用户建立 SSH 连接:gparasha”我的理解错了。
我有一个文件,其中有一些名称逐行列出.
gparasha-macOS:python_scripting gparasha$ cat topology_list.txt
First-Topology
Third-topology
Second-Topology
Run Code Online (Sandbox Code Playgroud)
现在我试图迭代这些内容,但我无法这样做.
file = open('topology_list.txt','r')
print file.readlines()
for i in file.readlines():
print "Entered For\n"
print i
topology_list = file.readlines()
print topology_list
Run Code Online (Sandbox Code Playgroud)
file.readlines()以列表形式打印文件的行.所以我得到了这个:
['First-Topology\n', 'Third-topology\n', 'Second-Topology\n']
Run Code Online (Sandbox Code Playgroud)
但是,当我遍历此列表时,我无法这样做.
此外,当我将它分配给变量'topology_list'时,如倒数第二行并打印它.它给了我一个空列表.
[]
Run Code Online (Sandbox Code Playgroud)
所以我有两个问题.
我的做法有什么问题?怎么做到这一点?
我正在尝试使用 Ansible 自动执行一些任务。在我的剧本中,我有一个复制任务,然后更改文件的权限。我需要在执行此任务后重新启动该服务。我包括了通知并且还声明了我的处理程序,但奇怪的是这个处理程序永远不会被调用。
摘自我的剧本
- name: Configure Audit Log Purge Scheduler
copy:
src: "Scheduler-Log-Purge.config"
dest: "{{ crx_dir }}install/com.adobe.cq.audit.purge.Scheduler-LogPurge.config"
become: true
tags: aem
- name: Change Permissions of the Log Purge Scheduler config File
file:
path: "{{ crx_dir }}install/com.adobe.cq.audit.purge.Scheduler-LogPurge.config"
owner: crx
group: crx
become: true
notify: restart aem
tags: aem
- name: Pause the execution for cq5 to come up
pause:
minutes: 5
tags: aem
Run Code Online (Sandbox Code Playgroud)
这是我的处理程序文件内容。
---
- name: restart aem
service: name=cq5 state=restarted
become: yes
Run Code Online (Sandbox Code Playgroud)
运行剧本后的o/p
gparasha-macOS:TLTD gparasha$ ansible-playbook -i …Run Code Online (Sandbox Code Playgroud) 我是boto3的新手,并且正在使用它来自动注册和从负载均衡器注销EC2实例的过程.
这是我的示例Python代码:
import boto3
elbList = boto3.client('elb')
bals = elbList.describe_load_balancers()
for elb in bals['LoadBalancerDescriptions']:
print 'ELB Name:' + elb['LoadBalancerName'] + 'ELB scheme type: ' + elb['Scheme']
Run Code Online (Sandbox Code Playgroud)
此脚本仅列出我的所有经典负载均衡器,但未列出我的应用程序负载均衡器.
如何列出我的应用程序负载均衡器并列出附加到它的所有实例?