ansible all -i localhost, -m debug -a "msg={{ 'apassword' | password_hash('sha512', 'mysecretsalt') }}"
输出:
$6$mysecretsalt$zBxKrtoLhJ5.ng.yl/fEzEydPGmEruaDLH1Bt7uLqumt8SDFjhxGGwm7bzQoQODGkNhY.GhYf2zBdncB8gH4s0
进而:
ansible app -m user -a "name=alice password=$6$mysecretsalt$zBxKrtoLhJ5.ng.yl/fEzEydPGmEruaDLH1Bt7uLqumt8SDFjhxGGwm7bzQoQODGkNhY.GhYf2zBdncB8gH4s0"
ssh alice@ip
,使用“appssword”失败,但使用passwd
命令可以登录。