我正在尝试创建一个ansible剧本,以便从k8s默认名称空间中删除特定的荚。
有两份清单:
pod_list (用kubectl get pods命令输出动态创建)
pod_filter (预定义的正则表达式,或者仅仅是荚名的开头)
其思想是迭代pod_list并筛选出与pod_filter中指定的模式匹配的名称。
剧本:
---
- name: Delete specific pods
hosts: localhost
vars:
pod_filter:
- hello # beginning of the pod name
- m
ansible/ansible-剧本版本: 2.1.2.0 / 2.2.0.0
我试图使用yum/apt安装一个包,但是由于用于安装包的存储库位于packagecloud.io中,有时我会收到一条错误消息(当我在运行我的ansible-playbook时传递-vvv )。
[Errno 14] curl#56 - \"TCP connection reset by peer\"\nTrying other mirror. ...some ansible verbose text here.. [Errno 256] No more mirrors to try.
这种事并不总是
我的目标是在思科交换机上的接口上循环,检查access vlan,然后在设置为" 12“时更改vlan,或者在设置为12以外的情况下保持原样。为此,我将结果保存到"int_out":
- name: check vlan on some interfaces and save to int_out
ios_command:
commands: show run int Fa0/{{ item }} | incl switchport access vlan
provider: "{{ cli }}"
wi
我在when语句中使用ansible_hostname变量在命令stdout中查找包含它的字符串,如下所示: when: result.stdout.find("some stdout text {{ansible_hostname}}") == -1 或 when: result.stdout.find("some stdout text {{ansible_hostname}}") != -1 我的任务按预期工作,但ansible在when语句中抛出了有关使用jinja2模板的警告: [WARNING]: when statements should no
从bash函数中,我想调用python脚本,它提示输入,我需要使用python -m作为模块运行该脚本。
这是select_pod.py
# above this will be a print out of pods
pod = input('Pick pod')
print(pod)
下面是bash函数:
function foo() {
POD=$(python3 -m select_pod)
kubectl exec $POD --stdin --tty bash
}
我不能让输入开始工作。“挑荚”没有打印到终端上。