我的目标是在思科交换机上的接口上循环,检查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
我运行了一个任务来捕获多个设备的接口状态,在某些情况下还会捕获多个接口的状态,但我一次只能检索一个stdout_lines,但我需要检索运行该命令的主机的所有stdout_lines。我有任务代码来访问列表的各个stdout_lines,但不是全部。 - name: Execute IOS command to check port state up/down before configuration
ios_command:
commands:
- "show ip int brief | in {{item}}"
当我运行ansible playbook脚本mod使用shell脚本时,我不希望在stdout_lines第一个元素中得到答案"\r\n“。
一些计算机在第一次返回\r\n
shell脚本:
#!/bin/bash
echo "Hi"
剧本:
---
- hosts: test
tasks:
- script: echoTest.sh
register: out
- debug:
var: out
most are the expected answer:
"out": {
这是ansible的新手--这就是我想要做的。我已经创建了一个行动手册来监控一些服务器。攻略中的一项任务是检查服务器是否成功备份。
以下是任务:
-name: Grabbing all of the files that were created today on Server1
shell: find /back/up/location/ -maxdepth 1 -daystart -ctime 0 -print
with_items:
- '{{ inventory_hostname }}'
when: item == "Server1"
re
我需要使用bash编写一个ansible模块(因为我不知道python)。这是我在我的剧本中使用的shell模块,它是有效的:
- name: Finding out what web server it uses
shell: "lsof -i :80 | grep LISTEN | cut -d ' ' -f 1"
register: result
- name: output the result of what web server it uses
debug: msg="{{ result.stdout
这是我第一次在网格目录下运行vagrant up时收到的错误消息: TASK [wordpress-install : Install Dependencies with Composer] ******************
System info:
Ansible 2.9.0; Vagrant 2.2.6; Darwin
Trellis Head
---------------------------------------------------
Composer could not find a composer.json file in /srv/www/example.com/