-
Notifications
You must be signed in to change notification settings - Fork 0
/
play-basic.yml
57 lines (42 loc) · 1.35 KB
/
play-basic.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
49
50
51
52
53
54
55
56
57
---
#
# Basic setup
#
- hosts: all
tasks:
- debug: var=play_hosts
- debug: var=groups.all
- apt: update_cache=yes
- apt: pkg={{item}} state=latest
with_items: [ 'vim', 'tree', 'jq', 'curl', 'screen', 'htop', 'bash-completion']
- hostname: name={{hostname}}
when: hostname is defined
- name: Update /etc/hosts with local hostname
lineinfile:
dest: /etc/hosts
regexp: '^127\.0\.1\.1'
line: '127.0.1.1 {{ansible_hostname}} {{hostname}}'
state: present
when: hostname is defined
- name: Update /etc/hosts
lineinfile:
dest: /etc/hosts
regexp: "^{{h.ipv4_address | replace('.', '\\.') }}"
line: '{{h.ipv4_address}} {{h.fqdn}} {{item}}'
insertafter: '^127\.0\.1\.1'
state: present
with_items: '{{groups.all}}'
vars:
h: '{{hostvars[item]}}'
- group: name=wheel state=present
- name: Add rules for sudoers (wheel)
copy:
dest: /etc/sudoers.d/wheel
content: '%wheel ALL=(ALL) NOPASSWD:ALL'
- file: path=~/bin state=directory
- copy: src=files/{{item.key}} dest=~/{{item.value}} mode=0644
with_dict: { 'profile': '.profile', 'bashrc': '.bashrc', 'vimrc': '.vimrc' }
- authorized_key:
user: root
state: present
key: '{{lookup("file", "keys/id_rsa.pub")}}'