aboutsummaryrefslogtreecommitdiffstats
path: root/roles/gitlab-ci-generator/templates/gitlab-ci.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/gitlab-ci-generator/templates/gitlab-ci.yml')
-rw-r--r--roles/gitlab-ci-generator/templates/gitlab-ci.yml204
1 files changed, 204 insertions, 0 deletions
diff --git a/roles/gitlab-ci-generator/templates/gitlab-ci.yml b/roles/gitlab-ci-generator/templates/gitlab-ci.yml
new file mode 100644
index 0000000..51ceb05
--- /dev/null
+++ b/roles/gitlab-ci-generator/templates/gitlab-ci.yml
@@ -0,0 +1,204 @@
+---
+################################################################################
+#
+# !! DO NOT EDIT MANUALLY !!
+#
+# This file is generated by gitlab-ci-generator
+#
+################################################################################
+
+stages:
+{% for stage in stages %}
+ - {{ stage }}
+{% endfor %}
+
+variables:
+ GIT_SUBMODULE_STRATEGY: recursive
+ VAULT_FILE: .vault
+
+################################################################################
+# Shared parameters
+################################################################################
+.runner_tags: &runner_tags
+ tags:
+{% for tag in runner.tags %}
+ - {{ tag }}
+{% endfor %}
+
+.syntax_checking: &syntax_checking
+ only:
+ - pushes
+ stage: lint
+
+.artifacts_root: &artifacts_root
+ name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
+ paths:
+ - vars/
+ - inventory/
+
+.artifacts: &artifacts
+ artifacts:
+ <<: *artifacts_root
+ expire_in: 15 days
+
+.artifacts_longexpire: &artifacts_longexpire
+ artifacts:
+ <<: *artifacts_root
+ expire_in: 1 yrs
+
+.runner_env: &runner_env
+{% for var_name, var_value in runner.env_vars.items()|default({'foo': 'bar'}) %}
+ {{ var_name }}: "{{ var_value }}"
+{% endfor %}
+
+################################################################################
+# Linting
+################################################################################
+
+yaml_checking:
+ <<: *syntax_checking
+ <<: *runner_tags
+ variables:
+ <<: *runner_env
+ image: {{ runner.docker_proxy }}sdesbure/yamllint:latest
+ script:
+ - >
+ yamllint -d "line-length: {
+ max: 80,
+ allow-non-breakable-words: true,
+ allow-non-breakable-inline-mappings: true}"
+ .gitlab-ci.yml
+ - yamllint *.yml
+
+ansible_linting:
+ <<: *syntax_checking
+ <<: *runner_tags
+ variables:
+ <<: *runner_env
+ image: {{ runner.docker_proxy }}sdesbure/ansible-lint:latest
+ script:
+ - ansible-lint -x ANSIBLE0010,ANSIBLE0013 run-ci.yml
+
+{% if not (disable_pages | default(false)) %}
+################################################################################
+# Pages
+################################################################################
+
+pages:
+ image: {{ runner.docker_proxy }}{{ runner.image }}:{{ runner.image_tag }}
+ stage: lint
+ <<: *runner_tags
+ variables:
+ <<: *runner_env
+ script:
+ - ./chained-ci-vue/init.sh ./pod_inventory
+ artifacts:
+ paths:
+ - public
+ only:
+ - master
+ except:
+ - triggers
+ - api
+ - external
+ - pipelines
+ - schedules
+ - web
+
+{% endif %}
+
+################################################################################
+# Jobs
+################################################################################
+
+.vault_mgmt: &vault_mgmt
+ before_script:
+ - echo ${ANSIBLE_VAULT_PASSWORD} > ${PWD}/${VAULT_FILE}
+ after_script:
+ - rm -f $PWD/.vault
+
+.set_config: &set_config
+ <<: *runner_tags
+ <<: *vault_mgmt
+ image: {{ runner.docker_proxy }}{{ runner.image }}:{{ runner.image_tag }}
+ script:
+ - >
+ ansible-playbook -i pod_inventory/inventory --limit ${pod}
+ --vault-password-file ${PWD}/${VAULT_FILE}
+ ${ansible_verbose} artifacts_init.yml
+
+.run_ci: &run_ci
+ <<: *runner_tags
+ <<: *vault_mgmt
+ image: {{ runner.docker_proxy }}{{ runner.image }}:{{ runner.image_tag }}
+ script:
+ - >
+ ansible-playbook -i pod_inventory/inventory --limit ${pod}
+ --extra-vars "step=${CI_JOB_NAME%:*}"
+ --vault-password-file ${PWD}/${VAULT_FILE}
+ ${ansible_verbose} run-ci.yml
+
+.trigger: &trigger
+ <<: *runner_tags
+ <<: *vault_mgmt
+ image: {{ runner.docker_proxy }}{{ runner.image }}:{{ runner.image_tag }}
+ script:
+ - >
+ ansible-playbook -i pod_inventory/inventory --limit ${pod}
+ --vault-password-file ${PWD}/${VAULT_FILE}
+ ${ansible_verbose} --extra-vars "step=trigger" trigger_myself.yml
+
+{% for pipeline in groups['all'] %}
+################################################################################
+# {{ pipeline }}
+################################################################################
+
+.{{ pipeline }}_global: &{{ pipeline }}_global
+ variables:
+ pod: {{ pipeline }}
+ <<: *runner_env
+{% if hostvars[pipeline].environment is defined %}
+ environment:
+ name: {{ hostvars[pipeline].environment }}
+{% endif %}
+ only:
+ variables:
+ - $POD == "{{ pipeline }}"
+{% if hostvars[pipeline].inpod is defined %}
+ - $INPOD == "{{ hostvars[pipeline].inpod }}"
+{% endif %}
+ refs:
+ - web
+ - schedules
+ - triggers
+
+{% for stage in stages %}
+{% for task in hostvars[pipeline].scenario_steps %}
+{% if hostvars[pipeline].scenario_steps[task].stage | default(
+ gitlab.git_projects[hostvars[pipeline].scenario_steps[task].project].stage
+ ) == stage %}
+{{ task }}:{{ pipeline }}:
+ stage: {{ stage }}
+ <<: *{{ pipeline }}_global
+{% if hostvars[pipeline].scenario_steps[task].project == 'config' %}
+ <<: *set_config
+{% elif hostvars[pipeline].scenario_steps[task].project == 'trigger' %}
+ <<: *trigger
+{% else %}
+ <<: *run_ci
+{% endif %}
+{% if (hostvars[pipeline].scenario_steps[task].pull_artifacts
+ | default(gitlab.git_projects[hostvars[pipeline].scenario_steps[task].project].pull_artifacts)
+ | default(false))
+ or task == 'config' %}
+ <<: *artifacts{% if hostvars[pipeline].longlife_artifact | default(false) | bool %}_longexpire{% endif %}
+
+{% endif %}
+{% endif %}
+{% endfor %}
+{% endfor %}
+
+{% endfor %}
+##
+# End of generated file
+##