Skip to content

Instantly share code, notes, and snippets.

@isopan
Last active August 29, 2015 14:15
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 isopan/a5c1bca7ae7ebd10688e to your computer and use it in GitHub Desktop.
Save isopan/a5c1bca7ae7ebd10688e to your computer and use it in GitHub Desktop.
/////ansibleサーバー、ansibleクライアントで実行
//ユーザーの作成
# groupadd ansible
# useradd ansible -g ansible
/////ansibleサーバーで実行
//パスワードなしキー作成
# su - ansible
$ sudo yum install ansible
$ cd /home/ansible/.ssh/
$ ssh-keygen -t rsa
$ ls
id_rsa id_rsa.pub
$ vi config
Host 192.168.1.2
HostName 192.168.1.2
IdentityFile ~/.ssh/id_rsa
User ansible
$ scp ./id_rsa.pub ansible@192.168.1.2:/home/ansible/.ssh/
/////ansibleクライアントで実行
//鍵を設定
# su - ansible
$ cd /home/ansible/.ssh/
$ cat id_rsa.pub >> authorized_keys
$ chmod 0600 authorized_keys
$ exit
//ansibleユーザーにsudo権限を付与
# visudo
ansible ALL=(ALL) NOPASSWD: ALL
/////ansibleサーバーで実行
$ ansible 192.168.1.2 -m ping
192.168.1.2 | success >> {
"changed": false,
"ping": "pong"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment