- 积分
- 16843
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
Basically username has the hostname as a variable.; h3 d/ |9 p9 F% f* J* p, `9 f
% O3 V" \0 @% N; i8 TNow our inventory has just IPs with group web.- {) p- Z) {7 @9 t/ F! v: t) c
# m, O1 t2 p/ c1 P) b- M
> cat inventory.txt
/ w+ z5 w0 m0 S[host]
9 ]$ O9 {1 m. ]& ^172.16.2.88 a3 f. v8 z2 y
172.16.x.y [; N' k1 {7 p% z6 e" T
172.16.y.z7 L: K. d( a" R, h# F. l
My playbook yml has ansible user as following.3 g" w1 W, t( I o- c' H
1 U/ F' E; F% q; C! {2 B
> cat uptime.yml4 N5 q) Y. o* \+ |/ g" ^
- hosts: host, H1 P/ W5 q5 x6 y
vars:8 M2 ?5 J5 u, z7 B0 |7 W+ J
ansible_ssh_port: xxxx9 ?# G P+ i9 d1 }- | S
ansible_user: bob~1234~{{inventory_hostname}}
7 m0 r4 P0 |/ H2 r* \8 W tasks:. T. e& Q e3 l3 G1 S
- name: Run uptime command" ?3 q! b: U. Z/ R- z: J/ q" }
shell: uptime9 t- i# ~; ?3 Y- C! k8 ^9 w Y( j
However, when I use following ansible-playbook command, it gives error for incorrect username.
$ o' L$ N8 Z, H: e' I
+ x2 H# M* z5 | N, y5 O4 F> ansible-playbook -v uptime.yml -i inventory.txt --private-key=key.pem
( P) a5 w q( h5 q7 [Please help me find correct ansible_user in playbook which has hostname as a variable inside.
0 [' s. q8 E9 i+ F: G+ a o+ ^* }/ ~" U) d
|
|