Created
April 28, 2015 12:40
-
-
Save noblejasper/a7ee36ae9a24628ec3c4 to your computer and use it in GitHub Desktop.
[調査中] Ansible で何人かのユーザーをroot@でもログイン出来るようにしたい
This file contains 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
# TODO: ルートユーザーにauthorized_keysを足すのが上手くいってない | |
# root_usersには該当するユーザー名のリストが入っている | |
# 各ユーザーのauthorized_keysを持ってきて root に足したい | |
# 各ユーザーのkeysが複数行だった場合にどんどん行数が増えてしまう | |
# そして冪等性が保たれない。つらい | |
- name: read root user's authorized_keys | |
shell: cat /home/{{item}}/.ssh/authorized_keys | |
with_items: root_users | |
register: output_keys | |
- name: write root keys that readed keys | |
lineinfile: | |
dest: /root/.ssh/authorized_keys | |
line: "{{ item.stdout }}" | |
regexp: "^.*{{ item.stdout[-10:] }}$" | |
create: yes | |
state: present | |
with_items: output_keys.results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
結論
実際のコード