Skip to content

Instantly share code, notes, and snippets.

@sechiro
Created October 12, 2019 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sechiro/315d6ef29bd58af1f6dd6b63dacbeac5 to your computer and use it in GitHub Desktop.
Save sechiro/315d6ef29bd58af1f6dd6b63dacbeac5 to your computer and use it in GitHub Desktop.
Amazon Linux 2で初期サーバにユーザ作成する手順
#!/bin/bash
sudo amazon-linux-extras install ansible2
sechiro ALL=(ALL) NOPASSWD: ALL
- hosts: localhost
tasks:
- name: Add sechiro user
become: yes
user:
name: sechiro
- name: Set authorized key taken from file
become: yes
become_user: sechiro
authorized_key:
user: sechiro
state: present
key: https://github.com/sechiro.keys
- name: Copy a new "sudoers" file into place, after passing validation with visudo
become: yes
copy:
src: sechiro_sudoers
dest: /etc/sudoers.d
validate: /usr/sbin/visudo -cf %s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment