我有一个角色名称 system_check。
系统启动后,我需要等到这个角色成功。
有没有办法重复运行这个角色直到它成功?
最佳答案
Q: "Is there a way to running a role until it succeeds in a play?"
答:这是不可能的。模块include_role说
Ignores some keywords, like until and retries.
相反,请使用 ansible-runner .例如 Use Runner as a standalone command line tool并测试artifacts (rc,状态,标准输出)。
例如
#!/bin/bash
rcfile=private1/artifacts/ID01/rc
statusfile=private1/artifacts/ID01/status
ansible-runner -p test.yml -i ID01 run private1
rc=$(cat $rcfile)
echo "rc: $rc"
until [ "0" == "$rc" ]; do
ansible-runner -p test.yml -i ID01 run private1
rc=$(cat $rcfile)
echo "rc: $rc"
done
$ tree private1
private1
├── artifacts
├── daemon.log
├── env
│ ├── envvars
│ ├── extravars
│ ├── passwords
│ ├── settings
│ └── ssh_key
├── inventory
│ └── hosts
└── project
├── roles
│ └── testrole
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── README.md
│ ├── tasks
│ │ └── main.yml
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ └── main.yml
└── test.yml
关于ansible - 有没有办法让角色在戏剧中成功之前?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59028334/