Guillaume Coré
2020-03-10 d68cfcdaa82fadc0fbca485d854458c3ab92bfdf
Fix and improve static (travis) checks

- disable unused checks
- deactivate python2, use python38
- update python requirements
- travis.yml: disable python2
- fix ocp4-ha-lab sample-vars
- download linklight before running tests
- keep ANSIBLE_REPO_PATH only for linklight
- Add lifecycle to tests
1 files deleted
11 files modified
222 ■■■■■ changed files
.travis.yml 3 ●●●● patch | view | raw | blame | history
ansible/configs/linklight/sample_vars.yml 3 ●●●● patch | view | raw | blame | history
ansible/configs/ocp4-cluster/destroy_env.yml 7 ●●●●● patch | view | raw | blame | history
ansible/configs/ocp4-ha-lab/sample_vars.yaml 3 ●●●● patch | view | raw | blame | history
ansible/configs/rhte-ans-tower/sample_vars.yml 10 ●●●● patch | view | raw | blame | history
ansible/configs/rhte-ans-tower/sample_vars_babylon.yml 20 ●●●● patch | view | raw | blame | history
ansible/configs/sap-hana/sample_vars.yml 19 ●●●●● patch | view | raw | blame | history
tests/static/requirements.txt 10 ●●●● patch | view | raw | blame | history
tests/static/syntax-check.sh 73 ●●●●● patch | view | raw | blame | history
tests/static/test-requirements.txt 42 ●●●●● patch | view | raw | blame | history
tests/static/tox-inventory.txt 15 ●●●●● patch | view | raw | blame | history
tests/static/tox.ini 17 ●●●● patch | view | raw | blame | history
.travis.yml
@@ -9,8 +9,7 @@
language: python
python:
  - "2.7"
  - "3.5"
  - "3.8"
install:
  - pip install --upgrade pip
ansible/configs/linklight/sample_vars.yml
@@ -1,4 +1,4 @@
# sample vars configuration file
# sample vars configuration file
#
# This file is passed to ansible-playbook to set key vars which need to be set
# and typically customized for a sucessful deployment.
@@ -22,3 +22,4 @@
student_total: 1
software_to_deploy: none
workshop_type: rhel
ansible/configs/ocp4-cluster/destroy_env.yml
@@ -54,13 +54,13 @@
    - cloud_provider != 'osp'
  - name: Run infra-azure-create-inventory Role
    import_role:
    include_role:
      name: infra-azure-create-inventory
    when:
    - cloud_provider == 'azure'
  - name: Run infra-gcp-create-inventory Role
    import_role:
    include_role:
      name: infra-gcp-create-inventory
    when:
    - cloud_provider == 'gcp'
@@ -71,7 +71,7 @@
  import_playbook: ../../cloud_providers/azure_ssh_config_setup.yml
  when:
    - cloud_provider != 'osp'
    - groups["bastions"] is defined
    - groups["bastions"] is defined
    - (groups["bastions"]|length>0)
  tags:
    - must
@@ -91,4 +91,3 @@
  when:
  - cloud_provider == 'azure' or
    cloud_provider == 'gcp'
ansible/configs/ocp4-ha-lab/sample_vars.yaml
@@ -1,6 +1,7 @@
---
guid: sampleguid
env_type: ocp4-ha-lab
cloud_provider: ec2
email: youare@redhat.com
install_ftl: false
cloud_tags: { 'Purpose': 'development' }
@@ -8,5 +9,5 @@
subdomain_base_suffix: openshift.opentlc.com
repo_version: 4.1.0
osrelease: 4.1.3
HostedZoneId:
HostedZoneId:
install_ocp4: false
ansible/configs/rhte-ans-tower/sample_vars.yml
@@ -9,7 +9,7 @@
root_filesystem_size: 20                #Size of the root filesystem
# Env config basics
env_type: ans-tower-prod                 # Name of config to deploy
env_type: rhte-ans-tower                 # Name of config to deploy
output_dir: /tmp                # Writable working scratch directory
email: name@example.com                 # User info for notifications
@@ -28,12 +28,12 @@
HostedZoneId: Z3IHLWJZOU9SRT            # You will need to change this
key_name: ocpkey                       # Keyname must exist in AWS
#Ansible Tower related vars
#Ansible Tower related vars
tower_version: 3.5.0-1                 # tower version you want to install
tower_version: 3.5.0-1                 # tower version you want to install
region: apac                           # region can not be with special characters in case of isolated node group
software_to_deploy: tower              # Define tower to install tower or none to have only infra ready.
worker: yes                            # Set yes to add isolated node group.
worker: yes                            # Set yes to add isolated node group.
worker_instance_count: 1             # Set 0 to not to provision worker(isolated) nodes.
@@ -72,7 +72,7 @@
# tower_organization:
#   - name: gpte
#   - name: BU
#   - name: BU
target_regions:
  - name: na
ansible/configs/rhte-ans-tower/sample_vars_babylon.yml
@@ -9,7 +9,7 @@
root_filesystem_size: 20                #Size of the root filesystem
# Env config basics
env_type: ans-tower-prod                 # Name of config to deploy
env_type: rhte-ans-tower                 # Name of config to deploy
output_dir: /opt/workdir               # Writable working scratch directory
email: name@example.com                 # User info for notifications
@@ -28,9 +28,9 @@
HostedZoneId: Z3IHLWJZOU9SRT            # You will need to change this
key_name: ocpkey                       # Keyname must exist in AWS
#Ansible Tower related vars
#Ansible Tower related vars
tower_version: 3.5.0-1                 # tower version you want to install
tower_version: 3.5.0-1                 # tower version you want to install
region: apac                           # region can not be with special characters in case of isolated node group
software_to_deploy: tower              # Define tower to install tower or none to have only infra ready.
tower_instance_count: 2
@@ -55,7 +55,7 @@
#     "subscription_name": "Ansible Tower by Red Hat (50 Managed Nodes), RHT Internal",
#     "trial": true
#   }
tower_host_name: "tower1.{{guid}}{{subdomain_base_suffix}}"
tower_host_name: "tower1.{{guid}}{{subdomain_base_suffix}}"
tower_user_accounts:                                      #Define users you want to create. Set superuser: yes to make user system wide System Administrator
  - user: babylon
@@ -75,7 +75,7 @@
tower_organization:
  - name: gpte
  - name: BU
  - name: BU
target_regions:
  - name: emea
@@ -88,8 +88,8 @@
    description: "babylon dev project"
    organization: "gpte"
    scm_url: "https://github.com/redhat-gpte-devopsautomation/babylon.git"
    #scm_type:
    #scm_credential:
    #scm_type:
    #scm_credential:
    scm_branch:  dev
    scm_update_on_launch: true
@@ -106,13 +106,13 @@
    description: "Empty inventory"
    organization: gpte
    # instance_group: ""
tower_job_templates:
  - name: babylon_job_runner
    description: "babylon job runner"
    job_type: run
    #vault_credential:
    #vault_credential:
    project: babylon
    playbook: job-runner.yml
    become: yes
@@ -147,7 +147,7 @@
  - name: job-runner-dev
    description: "babylon job runner dev"
    job_type: run
    #vault_credential:
    #vault_credential:
    project: babylon-dev
    playbook: job-runner.yml
    inventory: empty-inventory
ansible/configs/sap-hana/sample_vars.yml
File was deleted
tests/static/requirements.txt
@@ -1,11 +1,3 @@
# Versions are pinned to prevent pypi releases arbitrarily breaking
# tests with new APIs/semantics. We want to update versions deliberately.
ansible==2.6.14
boto==2.44.0
click==6.7
pyOpenSSL==17.5.0
# We need to disable ruamel.yaml for now because of test failures
#ruamel.yaml
six==1.10.0
shade==1.24.0
passlib==1.6.5
ansible==2.9.5
tests/static/syntax-check.sh
@@ -8,10 +8,36 @@
cd ${ORIG}
for i in ${static}/scenarii/*.{yaml,yml}; do
    config=$(basename "${i}")
for i in \
    $(find ${ORIG}/ansible/configs -name 'sample_vars*.y*ml' | sort) \
    ${static}/scenarii/*.{yaml,yml}; do
    echo
    echo '##################################################'
    echo "$(basename $(dirname ${i}))/$(basename ${i})"
    echo '##################################################'
    extra_args=()
    config=$(basename $(dirname "${i}"))
    if ! egrep --quiet ^env_type: ${i}; then
        echo "No env_type found in ${i}"
    fi
    env_type=$(egrep ^env_type: ${i}|cut -d' ' -f 2)
    # Linklight needs to be downloaded
    if [ "${env_type}" = linklight ]; then
        if [ ! -d ${ansible_path}/workdir/linklight ]; then
            echo "Download linklight"
            git clone https://github.com/ansible/workshops.git ${ansible_path}/workdir/linklight
        fi
        touch $(dirname "${i}")/env_secret_vars.yml
        extra_args=(
            -e ANSIBLE_REPO_PATH=${ansible_path}
        )
    fi
    if [ -e "${ansible_path}/configs/${env_type}/hosts" ]; then
        inventory=(-i "${ansible_path}/configs/${env_type}/hosts")
@@ -19,32 +45,27 @@
        inventory=(-i "${static}/tox-inventory.txt")
    fi
    echo
    echo '############################'
    echo "${config}"
    echo '############################'
    for playbook in \
        ${ansible_path}/main.yml \
        ${ansible_path}/destroy.yml \
        ${ansible_path}/configs/${env_type}/destroy_env.yml \
        ${ansible_path}/configs/${env_type}/scaleup.yml; do
        if [ -e "${playbook}" ]; then
            echo
            echo -n "With ANSIBLE_REPO_PATH: "
            ansible-playbook --syntax-check \
                             --list-tasks \
                             "${inventory[@]}" \
                             -e ANSIBLE_REPO_PATH=${ansible_path} \
                             "${playbook}" \
                             -e @${i}
            echo -n "Without ANSIBLE_REPO_PATH: "
        ${ansible_path}/destroy.yml; do
        ansible-playbook --syntax-check \
                         --list-tasks \
                         "${inventory[@]}" \
                         "${playbook}" \
                         ${extra_args[@]} \
                         -e @${i}
    done
    # lifecycle (stop / start)
            ansible-playbook --syntax-check \
                            --list-tasks \
                            "${inventory[@]}" \
                            "${playbook}" \
                            -e @${i}
        fi
    for ACTION in stop start status; do
        ansible-playbook --syntax-check \
                        --list-tasks \
                        "${inventory[@]}" \
                        ${ansible_path}/lifecycle_entry_point.yml \
                        ${extra_args[@]} \
                        -e ACTION=${ACTION} \
                        -e @${i}
    done
done
exit 0
tests/static/test-requirements.txt
@@ -1,14 +1,28 @@
# Versions are pinned to prevent pypi releases arbitrarily breaking
# tests with new APIs/semantics. We want to update versions deliberately.
# flake8 must be listed before pylint to avoid dependency conflicts
flake8==3.3.0
flake8-mutable==1.1.0
flake8-print==2.0.2
pylint==1.6.5
setuptools-lint==0.5.2
yamllint==1.6.1
coverage==4.3.4
mock==2.0.0
pytest==3.10.1
pytest-cov==2.4.0
astroid==2.3.3
attrs==19.3.0
coverage==5.0.3
entrypoints==0.3
flake8==3.7.9
flake8-mutable==1.2.0
flake8-print==3.1.4
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
mock==4.0.1
more-itertools==8.2.0
packaging==20.3
pathspec==0.7.0
pluggy==0.13.1
py==1.8.1
pycodestyle==2.5.0
pyflakes==2.1.1
pylint==2.4.4
pyparsing==2.4.6
pytest==5.3.5
pytest-cov==2.8.1
PyYAML==5.3
setuptools-lint==0.6.0
six==1.14.0
wcwidth==0.1.8
wrapt==1.11.2
yamllint==1.20.0
tests/static/tox-inventory.txt
@@ -50,3 +50,18 @@
[newnodes]
localhost
[managed_nodes]
localhost
[control_nodes]
localhost
[security_connection_check]
localhost
[satellites]
localhost
[utility]
localhost
tests/static/tox.ini
@@ -1,8 +1,9 @@
[tox]
minversion=2.3.1
envlist =
    py{27,35}-{flake8,pylint,unit}
    py27-{yamllint,ansible_syntax,generate_validation}
    #py{27,35}-{flake8,pylint,unit}
    #py27-{yamllint,ansible_syntax,generate_validation}
    py38-ansible_syntax
skipsdist=True
skip_missing_interpreters=True
@@ -12,13 +13,13 @@
deps =
    -r{toxinidir}/requirements.txt
    -r{toxinidir}/test-requirements.txt
    py35-flake8: flake8-bugbear==17.3.0
    #py35-flake8: flake8-bugbear==17.3.0
commands =
    unit: - pytest -c {toxinidir}/pytest.ini --rootdir=../../ {posargs}
    flake8: - flake8 --config={toxinidir}/.flake8 {posargs} ../../
    pylint: - python {toxinidir}/setup.py lint
    yamllint: - python {toxinidir}/setup.py yamllint -e .tox
    generate_validation: - python {toxinidir}/setup.py generate_validation
    #unit: - pytest -c {toxinidir}/pytest.ini --rootdir=../../ {posargs}
    #flake8: - flake8 --config={toxinidir}/.flake8 {posargs} ../../
    #pylint: - python {toxinidir}/setup.py lint
    #yamllint: - python {toxinidir}/setup.py yamllint -e .tox
    #generate_validation: - python {toxinidir}/setup.py generate_validation
    ansible_syntax: {toxinidir}/syntax-check.sh
    ansible_syntax: python {toxinidir}/setup.py ansible_syntax