-
Notifications
You must be signed in to change notification settings - Fork 0
/
iiac-workstation.yaml
176 lines (136 loc) · 4.85 KB
/
iiac-workstation.yaml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
---
# IIaC Workstation Playbook
-
# Hosts: where our play will run and options it will run with
hosts: localhost
connection: local
# Vars: variables that will apply to the play, on all targets
# Tasks: the list of tasks that will be executed within
# the play, this section can also be used for
# pre and post tasks
tasks:
- name: Set wsl2_environment fact default to false
set_fact:
wsl2_environment: false
- name: Set wsl2_environment fact true
set_fact:
wsl2_environment: true
when: ansible_kernel is search("microsoft-standard-WSL2")
- name: Set iiac_username
set_fact:
iiac_username: "{{ ansible_user_id }}"
- name: Display wsl2_environment and iiac_username
debug:
msg: "WSL2 = {{ wsl2_environment }} | iiac_username = {{ iiac_username }}"
# Handlers: the list of handlers that are executed as a notify
# key from a task
# Roles: list of roles to be imported into the play
-
# Hosts: where our play will run and options it will run with
hosts: localhost
connection: local
become: true
# Vars: variables that will apply to the play, on all targets
# Tasks: the list of tasks that will be executed within
# the play, this section can also be used for
# pre and post tasks
tasks:
- name: Install packages from pip
pip:
name:
- ansible-lint[yamllint]
- pywinrm
# Handlers: the list of handlers that are executed as a notify
# key from a task
# Roles: list of roles to be imported into the play
roles:
- role: geerlingguy.pip
-
# install keychain and git
hosts: localhost
connection: local
gather_facts: yes
become: true
tags: install_utilities
vars:
git_version: "2.36.1"
git_version_to_install: "1:{{ git_version }}-0ppa1~ubuntu20.04.1"
keychain_version: "2.8.5"
keychain_version_to_install: "{{ keychain_version }}-1"
keychain_version_expected: "{{ keychain_version }}.."
tasks:
- name: Add git PPA
shell: add-apt-repository --yes ppa:git-core/ppa
- name: Install git
apt:
name: "git={{ git_version_to_install }}"
- name: Install Keychain
apt:
name: "keychain={{ keychain_version_to_install }}"
update_cache: yes
- name: Get git version
shell: git version | sed 's/[[:alpha:]|(|[:space:]]//g'
register: installed_git_version
- name: Get keychain version
shell:
cmd: keychain -V 2> >(grep -i keychain) 2> >(sed 's/[[:alpha:]|(|[:space:]]//g') | fgrep '*' | sed 's/[*~://]//g'
executable: /bin/bash
register: installed_keychain_version
- name: Display git and keychain versions
debug:
msg: "git = {{ installed_git_version.stdout }} | keychain = {{ installed_keychain_version.stdout }}"
- name: Test git version
fail:
msg: "Git Version Error: Expected {{ git_version }} | Found {{ installed_git_version.stdout }}"
when: installed_git_version.stdout != git_version
- name: Test keychain version
fail:
msg: "Keychain Version Error: Expected {{ keychain_version_expected }} | Found {{ installed_keychain_version.stdout }}"
when: installed_keychain_version.stdout != keychain_version_expected
-
# Hosts: where our play will run and options it will run with
hosts: localhost
connection: local
become: true
# Vars: variables that will apply to the play, on all targets
# Tasks: the list of tasks that will be executed within
# the play, this section can also be used for
# pre and post tasks
# Handlers: the list of handlers that are executed as a notify
# key from a task
# Roles: list of roles to be imported into the play
roles:
- role: xanmanning.virtualbox
when: not wsl2_environment
- role: geerlingguy.docker
when: not wsl2_environment
- role: diodonfrost.vagrant
- role: andrewrothstein.terraform
- role: geerlingguy.packer
- role: gantsign.visual-studio-code
visual_studio_code_version: "1.65.2*"
users:
- username: "{{ iiac_username }}"
visual_studio_code_extensions:
- ms-azuretools.vscode-docker
- marcostazi.VS-code-vagrantfile
- HashiCorp.terraform
- 4ops.packer
- tomaciazek.ansible
-
# Hosts: where our play will run and options it will run with
hosts: localhost
connection: local
# Vars: variables that will apply to the play, on all targets
# Tasks: the list of tasks that will be executed within
# the play, this section can also be used for
# pre and post tasks
# Handlers: the list of handlers that are executed as a notify
# key from a task
# Roles: list of roles to be imported into the play
roles:
- role: diodonfrost.vagrant
vagrant_plugins:
- virtualbox_WSL2
when: wsl2_environment
...