diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..1cf307a --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,33 @@ +--- +name: Pull request +"on": + pull_request: +jobs: + lint: + runs-on: ubuntu-22.04 + permissions: {} + strategy: + fail-fast: false + matrix: + include: + # NOTE(upgrade): Keep these in sync with Kayobe's supported Ansible and Python versions (see release notes). + - ansible: "2.16" + python: "3.12" + name: Ansible ${{ matrix.ansible }} lint with Python ${{ matrix.python }} + steps: + - name: GitHub Checkout ๐Ÿ›Ž + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} ๐Ÿ + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Install dependencies ๐Ÿ“ฆ + run: | + python -m pip install --upgrade pip + pip install ansible-core==${{ matrix.ansible }}.* ansible-lint + + - name: Linting code ๐Ÿงช + run: | + ansible-lint -v --force-color diff --git a/ansible/generate-magnum-capi-templates.yml b/ansible/generate-magnum-capi-templates.yml index 0aa0016..45deec7 100644 --- a/ansible/generate-magnum-capi-templates.yml +++ b/ansible/generate-magnum-capi-templates.yml @@ -4,57 +4,59 @@ vars: root_dir: ../ tasks: - - - name: Check that required variables are defined - assert: - that: - - magnum_default_master_flavor_name is defined - - magnum_default_worker_flavor_name is defined - - magnum_external_net_name is defined - - magnum_loadbalancer_provider is defined - - - name: Fetch capi-helm-charts release information - ansible.builtin.uri: - url: https://api.github.com/repos/azimuth-cloud/capi-helm-charts/releases/latest - register: capi_helm_chart_release_data - - - name: Fetch dependencies.json for capi-helm-charts release - ansible.builtin.uri: - url: https://raw.githubusercontent.com/azimuth-cloud/capi-helm-charts/{{ capi_helm_chart_release_data.json.tag_name }}/dependencies.json - register: dependencies_response - - - name: Ensure wget packages is installed - become: true - package: - name: wget - state: present - - - name: Fetch manifest.json for capi-helm-charts images + - name: Check that required variables are defined + ansible.builtin.assert: + that: + - magnum_default_master_flavor_name is defined + - magnum_default_worker_flavor_name is defined + - magnum_external_net_name is defined + - magnum_loadbalancer_provider is defined + + - name: Fetch capi-helm-charts release information + ansible.builtin.uri: + url: https://api.github.com/repos/azimuth-cloud/capi-helm-charts/releases/latest + register: capi_helm_chart_release_data + + - name: Fetch dependencies.json for capi-helm-charts release + ansible.builtin.uri: + url: https://raw.githubusercontent.com/azimuth-cloud/capi-helm-charts/{{ capi_helm_chart_release_data.json.tag_name }}/dependencies.json + register: dependencies_response + + - name: Ensure wget packages is installed + become: true + ansible.builtin.package: + name: wget + state: present + + - name: Fetch manifest.json for capi-helm-charts images # noqa command-instead-of-module # ansible.builtin.uri: # url: https://raw.githubusercontent.com/azimuth-cloud/azimuth-images/{{ dependencies_response.json['azimuth-images'] }}/manifest.json # Above URL returns 404 even though similar URL for capi-helm-charts repo works fine # Not sure why but fall back to wget + JSON parsing for now. - shell: "wget -O - https://github.com/azimuth-cloud/azimuth-images/releases/download/{{ dependencies_response.json['azimuth-images'] }}/manifest.json" - register: manifest_response - changed_when: false - - - name: Parse JSON response - set_fact: - new_template_data: "{{ manifest_response.stdout | from_json | dict2items | selectattr('key', 'match', 'kubernetes*') | list }}" - - - name: Ensure output dir exists - ansible.builtin.file: - path: "{{ [root_dir, 'generated-magnum-snippets', now(utc=true,fmt='%Y-%m-%d-T%H-%M-%S')] | path_join }}" - state: directory - mode: '0755' - register: output_dir - - - name: Write new image config to file - template: - src: "magnum-capi-images.j2" - dest: "{{ output_dir.path }}/images.yml" - - - name: Write new cluster template config to file - template: - src: "magnum-capi-templates.j2" - dest: "{{ output_dir.path }}/templates.yml" + ansible.builtin.command: >- + wget -O - https://github.com/azimuth-cloud/azimuth-images/releases/download/{{ dependencies_response.json['azimuth-images'] }}/manifest.json + register: manifest_response + changed_when: false + + - name: Parse JSON response + ansible.builtin.set_fact: + new_template_data: "{{ manifest_response.stdout | from_json | dict2items | selectattr('key', 'match', 'kubernetes*') | list }}" + + - name: Ensure output dir exists + ansible.builtin.file: + path: "{{ [root_dir, 'generated-magnum-snippets', now(utc=true, fmt='%Y-%m-%d-T%H-%M-%S')] | path_join }}" + state: directory + mode: "0755" + register: output_dir + + - name: Write new image config to file + ansible.builtin.template: + src: "magnum-capi-images.j2" + dest: "{{ output_dir.path }}/images.yml" + mode: "0644" + + - name: Write new cluster template config to file + ansible.builtin.template: + src: "magnum-capi-templates.j2" + dest: "{{ output_dir.path }}/templates.yml" + mode: "0644" diff --git a/ansible/openstack.yml b/ansible/openstack.yml index 2438f9d..e07e441 100644 --- a/ansible/openstack.yml +++ b/ansible/openstack.yml @@ -1,10 +1,11 @@ --- # Top level playbook that includes all others. -- import_playbook: openstack-project.yml -- import_playbook: openstack-networks.yml -- import_playbook: openstack-flavors.yml -- import_playbook: openstack-images.yml -- import_playbook: openstack-host-aggregates.yml -- import_playbook: openstack-volume-types.yml -- import_playbook: openstack-container-clusters.yml -- import_playbook: openstack-ratings.yml + +- import_playbook: openstack-project.yml # noqa name[play] +- import_playbook: openstack-networks.yml # noqa name[play] +- import_playbook: openstack-flavors.yml # noqa name[play] +- import_playbook: openstack-images.yml # noqa name[play] +- import_playbook: openstack-host-aggregates.yml # noqa name[play] +- import_playbook: openstack-volume-types.yml # noqa name[play] +- import_playbook: openstack-container-clusters.yml # noqa name[play] +- import_playbook: openstack-ratings.yml # noqa name[play] diff --git a/etc/openstack-config/openstack-config.yml b/etc/openstack-config/openstack-config.yml index 9a2d951..83d2cf2 100644 --- a/etc/openstack-config/openstack-config.yml +++ b/etc/openstack-config/openstack-config.yml @@ -4,64 +4,64 @@ # List of OpenStack domains. Format is as required by the stackhpc.os-projects # role. -#openstack_domains: +# openstack_domains: # List of OpenStack projects. Format is as required by the stackhpc.os-projects # role. -#openstack_projects: +# openstack_projects: ############################################################################### # Configuration of networks, subnets and routers. # List of networks in the openstack system. Format is as required by the # stackhpc.os-networks role. -#openstack_networks: +# openstack_networks: # List of routers in the openstack project. Format is as required by the # stackhpc.os-networks role. -#openstack_routers: +# openstack_routers: # List of security groups in the openstack project. # Format is as required by the stackhpc.os-networks role. -#openstack_security_groups: +# openstack_security_groups: # List of RBAC definitions in the openstack projct. Format is as required by the # stackhpc.os-networks role. -#openstack_networks_rbac: +# openstack_networks_rbac: ############################################################################### # Configuration of nova flavors. # List of nova flavors in the openstack project. Format is as required by the # stackhpc.os-flavors role. -#openstack_flavors: +# openstack_flavors: ############################################################################### # Configuration of nova host aggregates. # List of nova host aggregates. Format is as required by the # stackhpc.os_host_aggregates role. -#openstack_host_aggregates: +# openstack_host_aggregates: ############################################################################### # Configuration of Glance software images. # List of Glance images. Format is as required by the stackhpc.os-images role. -#openstack_images: +# openstack_images: # List of Diskimage Builder (DIB) elements paths to include in image builds. -#openstack_image_elements: +# openstack_image_elements: # List of Diskimage Builder (DIB) elements Git repositories to use in image # builds. -#openstack_image_git_elements: +# openstack_image_git_elements: ############################################################################### # Configuration of Magnum container clusters. # List of magnum cluster templates. Format is as required by the # stackhpc.os-container-clusters role. -#openstack_container_clusters_templates: +# openstack_container_clusters_templates: ############################################################################### # Configuration variables for generating new Magnum cluster template config. @@ -100,35 +100,33 @@ # Configuration variables for a CloudKitty ratings service deployment. # # ### ####### ##### IN ORDER TO SUCCESSFULLY DEPLOY CLOUDKITTY -# # # # # # # 'cloudkitty.conf' & 'metrics.yml' MUST BE +# # # # # # # 'cloudkitty.conf' & 'metrics.yml' MUST BE # # # # # # ### PROVIDED ALONGSIDE THE FOLLOWING CONFIG. # # # # # # # MORE INFO CAN BE FOUND IN THE README.md # # ### # ##### 'stackhpc-kayobe-config' DOCS. - - -# A list where each item is a dictionary mapping the associated fields, +# A list where each item is a dictionary mapping the associated fields, # with the 'mappings' field also being a list of dictionaries. Example # of the mappings and their fields can be found below, however for more # information please refer to the stackhpc.openstack.os_ratings role docs. # -#openstack_ratings_hashmap_field_mappings: -# - service: SERVICE_NAME -# name: FIELD_NAME -# mappings: -# - value: MAPPING_VALUE -# cost: MAPPING_COST -# type: MAPPING_TYPE -# group: MAPPING_GROUP <---THIS IS OPTIONAL--- +# openstack_ratings_hashmap_field_mappings: +# - service: SERVICE_NAME +# name: FIELD_NAME +# mappings: +# - value: MAPPING_VALUE +# cost: MAPPING_COST +# type: MAPPING_TYPE +# group: MAPPING_GROUP <---THIS IS OPTIONAL--- # Much like the field mappings above, the service mappings are a list of # dictionaries, however these are not associated with a field. # -#openstack_ratings_hashmap_service_mappings: -# - service: SERVICE_NAME -# cost: MAPPING_COST -# type: MAPPING_TYPE -# group: MAPPING_GROUP <---THIS IS OPTIONAL--- +# openstack_ratings_hashmap_service_mappings: +# - service: SERVICE_NAME +# cost: MAPPING_COST +# type: MAPPING_TYPE +# group: MAPPING_GROUP <---THIS IS OPTIONAL--- ############################################################################### # Dummy variable to allow Ansible to accept this file. -workaround_ansible_issue_8743: yes +workaround_ansible_issue_8743: true diff --git a/examples/container-clusters.yml b/examples/container-clusters.yml index 4d85d20..a4af4aa 100644 --- a/examples/container-clusters.yml +++ b/examples/container-clusters.yml @@ -9,7 +9,7 @@ openstack_container_clusters_templates: # Kubernetes magnum cluster template. openstack_container_clusters_template_k8s_fedora_coreos: - labels: "heat_container_agent_tag=ussuri-stable-1,kube_tag=v1.18.9,cloud_provider_tag=v1.18.2,monitoring_enabled=true,auto_scaling_enabled=true,auto_healing_enabled=true,auto_healing_controller=magnum-auto-healer,magnum_auto_healer_tag=latest,master_lb_floating_ip_enabled=true,cinder_csi_enabled=true,ingress_controller=octavia" + labels: "heat_container_agent_tag=ussuri-stable-1,kube_tag=v1.18.9,cloud_provider_tag=v1.18.2,monitoring_enabled=true,auto_scaling_enabled=true,auto_healing_enabled=true,auto_healing_controller=magnum-auto-healer,magnum_auto_healer_tag=latest,master_lb_floating_ip_enabled=true,cinder_csi_enabled=true,ingress_controller=octavia" # noqa yaml[line-length] external-network: "external" master-flavor: "m1.medium" flavor: "m1.medium" diff --git a/examples/images.yml b/examples/images.yml index 925406c..88ace2d 100644 --- a/examples/images.yml +++ b/examples/images.yml @@ -34,7 +34,7 @@ openstack_image_centos_stream8: - "vm" - "grub2" - "stable-interface-names" - is_public: True + is_public: true env: YUM: dnf DIB_RELEASE: "8-stream" @@ -55,7 +55,7 @@ openstack_image_cirros_0_6_0: type: qcow2 image_url: "https://github.com/cirros-dev/cirros/releases/download/0.6.0/cirros-0.6.0-x86_64-disk.img" checksum: "md5:f4027b89e99e238184e13089a3155b74" - is_public: True + is_public: true properties: os_type: "linux" os_distro: "cirros" @@ -78,7 +78,7 @@ openstack_image_rocky8: - "grub2" - "stable-interface-names" - "openssh-server" - is_public: True + is_public: true packages: - "bash-completion" - "vim-enhanced" @@ -101,7 +101,7 @@ openstack_image_rocky8: openstack_image_ubuntu_focal: name: "Ubuntu-20.04" type: raw - is_public: True + is_public: true elements: # Required for UEFI mode: - "block-device-efi" diff --git a/examples/ratings.yml b/examples/ratings.yml index 19d7e3c..9a1d35a 100644 --- a/examples/ratings.yml +++ b/examples/ratings.yml @@ -3,34 +3,34 @@ # Configuration of CloudKitty for openstack. # Example configuration for registering CloudKitty fields. -# Included is mapping for various different compute flavors & -# a service mapping based on the stored image size in Glance. +# Included is mapping for various different compute flavors & +# a service mapping based on the stored image size in Glance. openstack_ratings_hashmap_field_mappings: - service: instance name: flavor_id mappings: - - value: '1' #tiny compute flavour with an OpenStack flavor ID of 1 + - value: "1" # tiny compute flavour with an OpenStack flavor ID of 1 cost: 1.0 group: instance_uptime_flavor_id type: flat - - value: '2' #small compute flavour with an OpenStack flavor ID of 2 + - value: "2" # small compute flavour with an OpenStack flavor ID of 2 cost: 2.0 group: instance_uptime_flavor_id type: flat - - value: '3' #medium compute flavour with an OpenStack flavor ID of 3 + - value: "3" # medium compute flavour with an OpenStack flavor ID of 3 cost: 3.0 group: instance_uptime_flavor_id type: flat - - value: '4' #large compute flavour with an OpenStack flavor ID of 4 + - value: "4" # large compute flavour with an OpenStack flavor ID of 4 cost: 4.0 group: instance_uptime_flavor_id type: flat - - value: '5' #xlarge compute flavour with an OpenStack flavor ID of 5 + - value: "5" # xlarge compute flavour with an OpenStack flavor ID of 5 cost: 5.0 group: instance_uptime_flavor_id type: flat - - value: '6' #tiny 2 compute flavour with an OpenStack flavor ID of 6 + - value: "6" # tiny 2 compute flavour with an OpenStack flavor ID of 6 cost: 2.0 group: instance_uptime_flavor_id type: flat @@ -42,8 +42,7 @@ openstack_ratings_hashmap_service_mappings: type: flat # # ### ####### ##### THIS CONFIGURATION FILE ONLY WORKS IF -# # # # # # # 'cloudkitty.conf' & 'metrics.yml' ARE +# # # # # # # 'cloudkitty.conf' & 'metrics.yml' ARE # # # # # # ### CONFIGURED CORRECTLY. MORE INFO CAN -# # # # # # # BE FOUND IN THE 'stackhpc-kayobe-config' +# # # # # # # BE FOUND IN THE 'stackhpc-kayobe-config' # # ### # ##### DOCS. -