-
Notifications
You must be signed in to change notification settings - Fork 54
/
sql2016_find_version.yml
executable file
·35 lines (29 loc) · 1.38 KB
/
sql2016_find_version.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
- name: Install SQL 2016
hosts: all
tasks:
- name: look for instance name
win_reg_stat:
path: HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server
register: sql_server_instance_names
- name: fail if no instance name found
fail:
msg: 'could not find MSSQL instance name'
when: sql_server_instance_names.properties.InstalledInstances.value is undefined or sql_server_instance_names.properties.InstalledInstances.value | length == 0
- name: find instance properties
win_reg_stat:
path: HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL
name: "{{ item }}"
register: sql_server_instance_name_properties
loop: "{{ sql_server_instance_names.properties.InstalledInstances.value }}"
- name: find instance information
win_reg_stat:
path: HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{{ item.value }}\Setup
register: sql_server_instance_information
loop: "{{ sql_server_instance_name_properties.results }}"
- name: set version information
set_fact:
sql_server_edition: "{{ sql_server_instance_information.results[0].properties.Edition.value }}"
sql_server_version: "{{ sql_server_instance_information.results[0].properties.Version.value }}"
- name: show sql server version
debug:
msg: "SQL server: {{ sql_server_edition }} - {{ sql_server_version }}"