- 积分
- 16843
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
Basically username has the hostname as a variable.* N! E1 I2 x* z! L" K7 u/ {
: o; E! R# G) O5 w( N6 t* ?% p6 y. sNow our inventory has just IPs with group web.
9 N" i+ b. x8 Y( r
- }' C. ~( y/ @" D> cat inventory.txt7 L9 U H" |5 X* l6 n
[host]
* ~& r' m1 S. x8 f& ^) \172.16.2.8
: C2 i4 p V1 P f# U6 S172.16.x.y
9 _( t+ H3 \' _ J) p: J/ p) c( D172.16.y.z5 _! J' a0 D$ }+ c! `
My playbook yml has ansible user as following. V0 H( c, j) L( n! q3 z
+ S/ w+ j& g) l: E0 q8 p; B) u> cat uptime.yml J' K1 F" V0 X5 E ^3 z4 b: X: n5 O
- hosts: host
2 s/ k( c8 P6 o6 m3 q% q2 X8 y( z vars:$ [# C* w) X5 o: Y, \" p( g
ansible_ssh_port: xxxx6 P7 z& h+ x' |2 v5 _% F. |
ansible_user: bob~1234~{{inventory_hostname}}7 u/ K- t; }0 y8 a
tasks:
. u2 e( i2 x1 r+ C2 W - name: Run uptime command- Y8 s; M3 ^, A- s, T! s4 k3 t( G
shell: uptime( `! z( k: h$ |2 {& n
However, when I use following ansible-playbook command, it gives error for incorrect username.! M$ W5 s- Z& w
( _) E7 F+ A5 h. k$ Y# s$ w> ansible-playbook -v uptime.yml -i inventory.txt --private-key=key.pem e/ z" e; `0 `
Please help me find correct ansible_user in playbook which has hostname as a variable inside.! @+ D/ a4 I8 y: V; a( u
: f+ s$ J$ n! Y- i [
|
|