Created
March 24, 2021 07:43
-
-
Save heiwa4126/b23ba838f0cd2600fe378ecb0d8c3a33 to your computer and use it in GitHub Desktop.
andibleのexpectモジュールの練習。微妙なコツがいるのがめんどくさい
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# andibleのexpectモジュールの練習 | |
# r7のfoobarユーザのパスワードをpasswdコマンドで変えてみる | |
# - 事前にfoobarユーザは作ってあるものとする(useradd foobar) | |
# - テストが終わったらfoobarユーザは消すこと(userdel foobar) | |
# | |
# # passwd foobar | |
# Changing password for user foobar. | |
# New password: | |
# Retype new password: | |
# passwd: all authentication tokens updated successfully. | |
- name: update foobar's password | |
hosts: r7 | |
become: true | |
gather_facts: false | |
vars: | |
foobar_passwd: Tarako7kagaMi | |
# TODO: パスワードを直書きするな | |
tasks: | |
- expect: | |
command: /bin/bash -c "LANG=C passwd foobar" | |
timeout: 5 | |
responses: | |
'New password:' : "{{ foobar_passwd }}" | |
'Retype new password:': "{{ foobar_passwd }}" | |
register: rc | |
changed_when: true | |
- debug: var=rc.stdout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment