LoginSignup
1
0

More than 3 years have passed since last update.

AWS上のWindowsServerに対して、ローカルmacからansibleを実行 #5 パスワード変更用のplaybook

Last updated at Posted at 2019-05-29

パスワード変更用のplaybook。
マニュアルは、https://docs.ansible.com/ansible/latest/modules/win_user_module.html

changePassword.yml
---
- hosts:
  - windows  # インベントリファイルで指定した名前

  tasks: 
  - name: change Administrator's password
    win_user: 
        # account_disabled:
        # account_locked: 
        # description: 
        # fullname: 
        # groups: 
        # groups_action: 
        name:  Administrator  # 必須
        password: パスワード名
        # password_expired: 
        # password_never_expires: 
        # state: 
        # user_cannot_change_password: 

必須パラメータはnameだけ。今回はパスワードを変えたいだけなので、
passwordだけ指定。

以下コマンドで実行。
ansible-playbook -i ./ansible/hosts ./ansible/changePassword.yml

コマンド実行結果

PLAY [windows] ************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************
ok: [ホスト名]

TASK [change Administrator's password] ************************************************************************************************
ok: [ホスト名]

PLAY RECAP ****************************************************************************************************************************
ホスト名 : ok=2    changed=0    unreachable=0    failed=0

2回目を実行したら、エラーが発生するようになった。
パスワードを変更したことにより、インベントリファイルのパスワードが変わっちゃったからである。
パスワード変更後は、インベントリファイルも修正するようにしよう。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0