blob: bcbfec430900cb1a23ef504237f2731861e08d00 [file] [log] [blame]
Dmitry Tyzhnenko35413c02018-03-05 14:12:37 +02001{% from 'virtual-mcp-pike-dvr-maas/underlay.yaml' import HOSTNAME_CFG01 with context %}
2{% from 'virtual-mcp-pike-dvr-maas/underlay.yaml' import HOSTNAME_CMP01 with context %}
3{% from 'virtual-mcp-pike-dvr-maas/underlay.yaml' import HOSTNAME_CMP02 with context %}
4{% from 'virtual-mcp-pike-dvr-maas/underlay.yaml' import HOSTNAME_GTW01 with context %}
5{% from 'virtual-mcp-pike-dvr-maas/underlay.yaml' import LAB_CONFIG_NAME with context %}
6{% from 'virtual-mcp-pike-dvr-maas/underlay.yaml' import DOMAIN_NAME with context %}
7
Dennis Dmitriev0f272312018-10-01 13:29:40 +03008{% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.com/salt-models/mcp-virtual-lab') %}
Dmitry Tyzhnenko35413c02018-03-05 14:12:37 +02009{% set CLUSTER_NAME = os_env('CLUSTER_NAME', LAB_CONFIG_NAME) %}
10# Other salt model repository parameters see in shared-salt.yaml
11
12{% import 'shared-salt.yaml' as SHARED with context %}
13
14{{ SHARED.MACRO_CONFIG_DAY01_SALT_MASTER() }}
15
16{{ SHARED.MACRO_CLONE_RECLASS_MODELS() }}
17
18- description: Import ssh key for jenkins user
19 cmd: |
20 mkdir -p /var/lib/jenkins/.ssh && \
21 ssh-keyscan cfg01 > /var/lib/jenkins/.ssh/known_hosts && \
22 chown jenkins /var/lib/jenkins/.ssh/known_hosts
23 node_name: {{ HOSTNAME_CFG01 }}
24 skip_fail: False
25
26- description: Upload maas config
27 upload:
28 local_path: {{ config.day1_cfg_config.templates_dir }}{{ LAB_CONFIG_NAME }}/
29 local_filename: {{ config.day1_cfg_config.cluster_maas_config }}
30 remote_path: /srv/salt/reclass/classes/cluster/{{ CLUSTER_NAME }}/infra/
31 node_name: {{ HOSTNAME_CFG01 }}
32 skip_fail: False
33
34- description: Rename maas config
35 cmd: mv -v /srv/salt/reclass/classes/cluster/{{ CLUSTER_NAME }}/infra/{{ config.day1_cfg_config.cluster_maas_config }} /srv/salt/reclass/classes/cluster/{{ CLUSTER_NAME }}/infra/maas.yml
36 node_name: {{ HOSTNAME_CFG01 }}
37 skip_fail: False
38
39- description: Save machines macs
40 cmd: |
41 echo -n '{{ config.day1_cfg_config.maas_machines_macs | tojson }}' | \
42 python -c 'import sys, yaml, json; yaml.safe_dump(json.load(sys.stdin), sys.stdout, default_flow_style=False)' > /srv/salt/reclass/classes/cluster/{{ CLUSTER_NAME }}/infra/maas-machines.yml
43 node_name: {{ HOSTNAME_CFG01 }}
44 skip_fail: False
45
46{#
47{{ SHARED.MACRO_INSTALL_FORMULAS(FORMULA_SERVICES='"fluentd"') }}
48
Vladimir Jigulinf557c562018-07-30 18:30:09 +040049{{ SHARED.MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='"linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx" "keystone" "mysql" "grafana" "haproxy" "rsyslog" "horizon" "prometheus" "telegraf" "elasticsearch" "powerdns" "fluentd" "logrotate"') }}
Dmitry Tyzhnenko35413c02018-03-05 14:12:37 +020050
51{{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
52
53{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/cluster/' + SHARED.CLUSTER_NAME + '/stacklight/server.yml') }}
54
55{{ SHARED.MACRO_GENERATE_INVENTORY() }}
56
57{{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
58#}
59
60{{ SHARED.MACRO_CONFIG_DAY01_SALT_MINION() }}
61
62- description: Fix config for Jenkins
63 cmd: |
64 export SALT_MASTER_MINION_ID={{ HOSTNAME_CFG01 }}
65 find /var/lib/jenkins/jenkins.model.JenkinsLocationConfiguration.xml -type f -print0 | xargs -0 sed -i -e 's/10.167.4.15/'$SALT_MASTER_DEPLOY_IP'/g'
66 node_name: {{ HOSTNAME_CFG01 }}
67 retry: {count: 1, delay: 1}
68 skip_fail: false
69
70- description: Setup pipeline libraries
71 cmd: |
72 export PIPELINE_REPO_URL=https://github.com/Mirantis
73 git clone --mirror $PIPELINE_REPO_URL/mk-pipelines.git /home/repo/mk/mk-pipelines/
74 git clone --mirror $PIPELINE_REPO_URL/pipeline-library.git /home/repo/mcp-ci/pipeline-library/
75 chown -R git:www-data /home/repo/mk/mk-pipelines/*
76 chown -R git:www-data /home/repo/mcp-ci/pipeline-library/*
77 node_name: {{ HOSTNAME_CFG01 }}
78 retry: {count: 1, delay: 5}
79 skip_fail: false
80
81
82- description: Refresh pillars before generating nodes
83 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False saltutil.refresh_pillar
84 node_name: {{ HOSTNAME_CFG01 }}
85 retry: {count: 1, delay: 5}
86 skip_fail: false
87
88- description: Sync all salt resources
89 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False saltutil.sync_all && sleep 5
90 node_name: {{ HOSTNAME_CFG01 }}
91 retry: {count: 1, delay: 5}
92 skip_fail: false
93
94- description: Configure network, linux, openssh and salt on cfg01 node
95 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls linux.network,linux,openssh,salt
96 node_name: {{ HOSTNAME_CFG01 }}
97 retry: {count: 2, delay: 5}
98 skip_fail: false
99
100#- description: Restart MaaS services before run state (need to prevent maas stucking)
101# cmd: systemctl restart maas-regiond && systemctl restart maas-rackd
102# node_name: {{ HOSTNAME_CFG01 }}
103# retry: {count: 1, delay: 5}
104# skip_fail: false
105
106- description: Configure MaaS(cluster) on cfg01 node
107 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls maas.cluster
108 node_name: {{ HOSTNAME_CFG01 }}
109 retry: {count: 1, delay: 5}
110 skip_fail: false
111
112- description: Configure MaaS(region) on cfg01 node
113 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls maas.region
114 node_name: {{ HOSTNAME_CFG01 }}
115 retry: {count: 3, delay: 5}
116 skip_fail: false
117
118- description: Configure reclass on cfg01 node
119 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls reclass
120 node_name: {{ HOSTNAME_CFG01 }}
121 retry: {count: 1, delay: 5}
122 skip_fail: false
123
124- description: Configure jenkins on cfg01 node
125 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls jenkins.client
126 node_name: {{ HOSTNAME_CFG01 }}
127 retry: {count: 1, delay: 5}
128 skip_fail: false