-
Notifications
You must be signed in to change notification settings - Fork 22
/
setup.yml
48 lines (39 loc) · 1.54 KB
/
setup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright 2015-2016 Harri Kapanen <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- hosts: all
become: yes
user: "{{ ansible_ssh_user }}"
handlers:
- include: handlers/handlers.yml
vars:
ssh_public_key: ~/.ssh/id_rsa.pub
vars_prompt:
- name: new_password
prompt: "Enter new password"
private: yes
tasks:
- name: Create .ssh
file: state=directory dest=/home/{{ ansible_ssh_user }}/.ssh/ owner={{ ansible_ssh_user }} group={{ ansible_ssh_user }}
- name: Push SSH key to the Raspberry Pi
copy: src={{ ssh_public_key }} dest=/home/{{ ansible_ssh_user }}/.ssh/authorized_keys owner={{ ansible_ssh_user }} group={{ ansible_ssh_user }}
- name: Change default user password
shell: echo {{ ansible_ssh_user }}:{{ new_password }} | sudo chpasswd
no_log: yes
- name: Expand filesystem
shell: "raspi-config --expand-rootfs"
become: yes
notify: reboot
- name: Show IP Address
debug: var=hostvars[inventory_hostname]['ansible_default_ipv4']['address']