summaryrefslogtreecommitdiffstats
path: root/ansible_collections/infinidat/infinibox/.gitlab-ci.yml
blob: ff749c98a57b58013ca2fbe19a55f5c85133cde6 (plain)
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
---
# Ref: https://docs.gitlab.com/ce/ci/yaml/README.html

# CICD environment variables:
# - VAULT_PASSWORD_FILE
#     - Type: File
#     - Key: VAULT_PASSWORD_FILE
#     - Value: <ansible vault password for the vars file for the ibox specified in --extra-vars>
#         - i.e. The password that allows one to view the file using "ansible-vault view <file>"

image: psusdev/gitlab-cicd:v0.14

playbook_testing:
  stage: test
  script:
    # Disable index-url = https://pypi.infinidat.com/simple.
    - mv ~/.pip/pip.conf ~/.pip/pip.conf.notused || true
    - python3 -m venv venv
    - . ./venv/bin/activate
    - python --version
    - export PIP_REQUIRE_VIRTUALENV=true
    - python -m pip install --upgrade pip
    - pip install -r requirements.txt
    - pip install -r requirements-dev.txt
    - echo "Requirements dump:"
    - pip freeze
    - echo
    - echo "Tested ansible version -> $(ansible --version)"

    # Build and install ansible collection. Find collection version from yml, strip quotes.
    - coll_version=$(spruce json galaxy.yml   | jq '.version'   | sed 's?"??g')
    - coll_namespace=$(spruce json galaxy.yml | jq '.namespace' | sed 's?"??g')
    - coll_name=$(spruce json galaxy.yml      | jq '.name'      | sed 's?"??g')
    - echo "Collection version   -> ${coll_version}"
    - echo "Collection namespace -> ${coll_namespace}"
    - echo "Collection name      -> ${coll_name}"  # gitlab's cilint does not like a colon here
    - echo "Collection tarball   -> ${coll_namespace}-${coll_name}-${coll_version}.tar.gz"
    - ansible-galaxy collection build
    - ansible-galaxy collection install "${coll_namespace}-${coll_name}-${coll_version}.tar.gz" -vvv
    # -p ./test_collection

    # Run testing playbooks
    - git_project="ansible-infinidat-collection"
    - echo "$git_project commit -> $(git log --max-count=1 --oneline)"
    - pushd ./playbooks > /dev/null
    - export ANSIBLE_CONFIG="/builds/PSUS/$git_project/playbooks/ansible.cfg"
    - export ANSIBLE_FORCE_COLOR=true
    - ibox_extra_vars="@../ibox_vars/iboxCICD.yaml"
    - verbosity="-v"
    - ansible-playbook --extra-vars "$ibox_extra_vars" --vault-password-file "$VAULT_PASSWORD_FILE" test_create_resources.yml "${verbosity}"
    - ansible-playbook --extra-vars "$ibox_extra_vars" --vault-password-file "$VAULT_PASSWORD_FILE" test_remove_resources.yml "${verbosity}"
    - popd > /dev/null

    # Show summery of execution tasks
    - ./scripts/test_summarize.sh general

    # Run testing map cluster playbooks
    - git_project="ansible-infinidat-collection"
    - echo "$git_project commit -> $(git log --max-count=1 --oneline)"
    - pushd ./playbooks > /dev/null
    - export ANSIBLE_CONFIG="/builds/PSUS/$git_project/playbooks/ansible.cfg"
    - export ANSIBLE_FORCE_COLOR=true
    - ibox_extra_vars="@../ibox_vars/iboxCICD.yaml"
    - verbosity="-v"
    - ansible-playbook --extra-vars "$ibox_extra_vars" --vault-password-file "$VAULT_PASSWORD_FILE" test_create_map_cluster.yml "${verbosity}"
    - ansible-playbook --extra-vars "$ibox_extra_vars" --vault-password-file "$VAULT_PASSWORD_FILE" test_remove_map_cluster.yml "${verbosity}"
    - popd > /dev/null

    # Show summery of execution tasks
    - ./scripts/test_summarize.sh map-cluster