nRnYqfrb5pJuTP5YAohj

Valid YAML

Nov 29th, 2018
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.18 KB | None | 0 0
  1. ---
  2. -
  3.   hosts: all
  4.   vars:
  5.     -
  6.       provision_password: '$6$w9S3t7x1kRtmG0u$6nVU9KZsC12Q8DYI4FtgKPy.e/cq/jseB/.DViTO1SpUnoCy.dxcOf8hyfitGq5V0yhgXccxzlqm2o.I3SlDJ0'
  7.   gather_facts: false
  8.   remote_user: root
  9.  
  10.   tasks:
  11.     -
  12.       name: "Add a new user named provision"
  13.       user: "name=provision password={{ provision_password }}"
  14.     -
  15.       copy:
  16.         content: "provision  ALL=(ALL)  NOPASSWD: ALL"
  17.         dest: /etc/sudoers.d/provision
  18.       name: "Add provision user to the sudoers"
  19.     -
  20.       authorized_key: "user=provision key=\"{{ lookup('file', '/home/provision/.ssh/id_rsa.pub') }}\" state=present"
  21.       name: "Deploy SSH Key"
  22.     -
  23.       lineinfile: "dest=/etc/ssh/sshd_config regexp='^PasswordAuthentication' line=\"PasswordAuthentication no\" state=present backup=yes"
  24.       name: "Disable Password Authentication"
  25.       notify:
  26.         - "restart ssh"
  27.     -
  28.       lineinfile: "dest=/etc/ssh/sshd_config regexp='^PermitRootLogin' line=\"PermitRootLogin no\" state=present backup=yes"
  29.       name: "Disable Root Login"
  30.       notify:
  31.         - "restart ssh"
  32.  
  33.   handlers:
  34.     -
  35.       name: "restart ssh"
  36.       service: "name=sshd state=restarted"
Advertisement
Add Comment
Please, Sign In to add comment