ansible-脚本・ボリュームユーザーの増加、バルクユーザパスワードを変更し、バッチは、ユーザーを削除

1、バッチユーザーを追加します。ansible-脚本のadduser.yml 

[ルート@ MGR〜]#猫adduser.yml  
--- 
-ホスト:すべての
  REMOTE_USER:ルート
  タスク:
    -ユーザー:名= "{{item.name}}"グループ= "{{item.group}}"パスワード= "{{ '123456' | password_hash( 'SHA512')}}" 
      with_items:
        - {名: "USER1"、グループ: "ルート"} 
        - {名: "USER2"、グループ: "ルート"} 
        - {名: "USER3"、グループ: "アパッチ"} 
[ルート@ MGR〜]#

2は、バッチユーザーのパスワード変更:ansible-脚本をmoduserpw.yml

[ルート@ MGR〜]#猫moduserpw.yml  
--- 
-ホスト:すべての
  REMOTE_USER:ルート
  タスク:
    -ユーザー:名= "{{item.name}}"グループ= "{{item.group}}"パスワード= "{{ '1234567' | password_hash( 'SHA512')}}" update_password =常に
      with_items:
        - {名: "USER1"、グループ: "ルート"} 
        - {名: "USER2"、グループ: "ルート"} 
        - {名: "USER3"は、基: "アパッチ"} 
[ルート@ MGR〜]#

3、一括削除ユーザー:ansible-脚本のdeluser.yml

[ルート@ MGR〜]#猫deluser.yml  
--- 
-ホスト:すべての
  REMOTE_USER:ルート
  タスク:
    -ユーザー:名= "{{item.name}}"グループ= "{{item.group}}"パスワード= "{{ '123456' | password_hash( 'SHA512')}}"状態=存在しない削除= YES  
      with_items:
        - {名"USER1"は、基: "ルート"} 
        - {名"USER2"は、基:「ルート「} 
        - {名: "USER3"、グループ: "アパッチ"} 
[ルート@ MGR〜]#


おすすめ

転載: blog.51cto.com/860143/2435111