-
Notifications
You must be signed in to change notification settings - Fork 1
/
provision-artifactory.yml
executable file
·115 lines (113 loc) · 4.88 KB
/
provision-artifactory.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
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
#!/usr/bin/env ansible-playbook
#
# (c) 2017 DataNexus Inc. All Rights Reserved
---
# Build our storm and zookeeper host groups
- name: Create artifactory host group
hosts: localhost
gather_facts: yes
vars_files:
- vars/artifactory.yml
tasks:
# load the 'configuration file' (if one was defined) to get any variables
# we might need during this playbook run
- name: Load configuration file
include_vars:
file: "{{config_file | default('config.yml')}}"
# if we're using dynamic provisioning; build the host groups from the
# meta-data associated with the matching nodes in the selected cloud
- block:
# get a list of the node_map entries for this application
- set_fact:
node_map_entries: "{{node_map | selectattr('application', 'equalto', application) | list}}"
- name: Fail playbook run if no {{application}} entries detected in the node_map
fail:
msg: "Missing {{application}} entry in 'node_map'"
when: (node_map_entries | length) == 0
- name: Fail playbook run if multiple {{application}} entries detected in the node_map
fail:
msg: "Multiple {{application}} entries detected in 'node_map'"
when: (node_map_entries | length) > 1
- name: Fail playbook run if attempting a multi-node deployment
fail:
msg: "Node count => {{node_map_entries[0].count}}; clustered {{application}} deployments not supported"
when: node_map_entries[0].count > 1
# build the artifactory host group from existing inventory
- include_role:
name: build-app-host-groups
vars:
host_group_list:
- name: artifactory
- set_fact:
num_artifactory_nodes: "{{groups['artifactory'] | default([]) | length}}"
# if an existing set of Cassandra nodes were found, throw an error unless
# the reuse_existing_nodes flag was set to 'true' or 'yes')
- block:
- name: Fail playbook run if existing nodes found and user did not request reuse
fail:
msg: "Found an existing set of nodes - {{((groups['artifactory'] | default([])) | to_yaml).split('\n').0}}; aborting playbook run"
when: not((reuse_existing_nodes | default(false)) | bool)
when: num_artifactory_nodes | int > 0
# if we're deploying instances in an cloud environment, ensure that there
# are an appropriately tagged set of nodes already (and launch them if
# they don't exist based on the node_map entries for this application)
- name: Launch AWS VMs
include_role:
name: 'aws'
when: num_artifactory_nodes | int == 0 and cloud == 'aws'
- name: Launch OSP VMs
include_role:
name: 'osp'
when: num_artifactory_nodes | int == 0 and cloud == 'osp'
when: cloud is defined and (cloud == 'aws' or cloud == 'osp')
# If we're dynamically provisioning, then do some final configuration on the
# VMs that were just launched (assuming that we're not re-using existing VMs)
- name: Complete OS configuration
hosts: artifactory
gather_facts: yes
vars_files:
- vars/artifactory.yml
tasks:
# first, initialize the play
- include_role:
name: initialize-play
vars:
gather_facts: false
skip_network_restart: true
# if this is a cloud deployment and we need to (re)configure nodes...
- block:
# then run the `preflight` role to finish the configuration of the nodes
# that were just allocated
- include_role:
name: preflight
vars:
mountpoint: "/data"
# and set a fact indicating that we (re)configured nodes in this play
- set_fact:
configured_nodes: true
when:
- cloud is defined and (cloud == 'aws' or cloud == 'osp')
- ((force_node_reconfig | default(false)) | bool) or not(hostvars['localhost']['matching_instances_found'])
# And deploy artifactory to the nodes in the `artifactory` host group; note
# that if there is more than one node in the `artifactory` host group, then an
# error will be thrown; this playbook does not support deployment of an
# artifactory cluster (clusterd deployments are a feature of the Enterprise
# version of artifactory, not the open-source version that is deployed by
# this playbook)
- name: Install/configure artifactory
hosts: artifactory
gather_facts: no
vars_files:
- vars/artifactory.yml
vars:
- combined_package_list: "{{ (default_packages|default([])) | union(artifactory_package_list) | union((install_packages_by_tag|default({})).artifactory|default([])) }}"
- artifactory_nodes: "{{groups['artifactory']}}"
pre_tasks:
# first, initialize the play
- include_role:
name: initialize-play
vars:
skip_network_restart: "{{configured_nodes | default(false)}}"
roles:
# now that we have all of the facts we need, provision the input nodes
- role: artifactory