LoginSignup
48

More than 5 years have passed since last update.

ansibleでsudo可能なユーザを追加する

Posted at

環境

  • ubuntu 14.04
  • ansible: 1.6.1
  • vagrant: 1.6.2

sudo可能なユーザを追加するplaybookの例

---
- hosts: webservers
  sudo: true
  vars:
    # created with:
    # openssl passwd -salt scibloaddx -1 *******
    password: $1$tekitoun$t293q2jBZPnzIljKNdGK..
  tasks:
    - user: name=yamada password={{password}} shell=/bin/bash state=present append=yes groups=sudo

パスワードの設定方法

ansibleのuserモジュールでパスワードを指定するときは、暗号化済みのものでないとならない。その値は、 openssl コマンドで計算することができる。

openssl passwd -salt tekitouna_salt -1 p@ssW0rd

参考文献

user - Manage user accounts — Ansible Documentation

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
48