From a6b750c77ed4de18f084c9264887b83dd444e492 Mon Sep 17 00:00:00 2001 From: Andrew Grimberg Date: Wed, 3 May 2023 08:47:44 -0700 Subject: [PATCH 1/1] Refactor: Update for pre-commit Change-Id: Ib15a07129c3e6a29ed75681af13c93e45a39a3e5 Issue-ID: CIMAN-33 Signed-off-by: Andrew Grimberg --- packer/README.markdown | 12 ++++---- packer/provision/helm.yaml | 61 ++++++++++++++++++------------------- packer/provision/local-builder.yaml | 26 ++++++++-------- packer/provision/local-docker.yaml | 46 ++++++++++++++++------------ packer/provision/memcached.yaml | 2 +- packer/provision/redis.yaml | 10 +++--- packer/templates/helm.json | 4 +-- packer/templates/memcached.json | 4 +-- packer/templates/redis.json | 4 +-- 9 files changed, 84 insertions(+), 85 deletions(-) diff --git a/packer/README.markdown b/packer/README.markdown index 1ef176a62..597e64b0d 100644 --- a/packer/README.markdown +++ b/packer/README.markdown @@ -26,12 +26,12 @@ This would build a bootable image in the Open-O CI cloud environment. From a high level, the builds: -* Boot a specified base image in the cloud -* Run a set of shell scripts, listed in the template's shell provisioner - section, to do any configuration required by the builder. -* Execute a shutdown of the running instance -* Execute a 'nova image-create' operation against the shutdown instance. -* Perform a 'nova delete' operation against the shutdown instance. +- Boot a specified base image in the cloud +- Run a set of shell scripts, listed in the template's shell provisioner + section, to do any configuration required by the builder. +- Execute a shutdown of the running instance +- Execute a 'nova image-create' operation against the shutdown instance. +- Perform a 'nova delete' operation against the shutdown instance. [1]: https://www.packer.io/ [2]: https://www.packer.io/intro/getting-started/setup.html diff --git a/packer/provision/helm.yaml b/packer/provision/helm.yaml index c5ce8a88b..4ccbecd63 100644 --- a/packer/provision/helm.yaml +++ b/packer/provision/helm.yaml @@ -11,65 +11,64 @@ chartmuseum_version: 0.15.0 tasks: - - name: 'Install kubectl {{kubectl_version}}' + - name: "Install kubectl {{kubectl_version}}" get_url: url: "https://storage.googleapis.com/kubernetes-release/release/v{{kubectl_version}}/bin/linux/amd64/kubectl" dest: /usr/local/bin/kubectl mode: 0775 - become: yes + become: true - - name: 'Install Helm3.8 {{helm3_8_version}}' + - name: "Install Helm3.8 {{helm3_8_version}}" block: - - name: 'Create directory /tmp/helm3.8' + - name: "Create directory /tmp/helm3.8" file: path: /tmp/helm3.8 state: directory - - name: 'Fetch tar.gz for Helm 3.8' + - name: "Fetch tar.gz for Helm 3.8" get_url: url: "https://get.helm.sh/helm-v{{helm3_8_version}}-linux-amd64.tar.gz" dest: /tmp/helm3.8 - - name: 'Unarchive Helm 3.8' + - name: "Unarchive Helm 3.8" unarchive: src: "/tmp/helm3.8/helm-v{{helm3_8_version}}-linux-amd64.tar.gz" dest: /tmp/helm3.8 remote_src: true - become: yes - - name: 'Move Helm 3.8 bin to /usr/local/bin and set as executable' - command: 'mv /tmp/helm3.8/linux-amd64/helm /usr/local/bin/helm3.8' - become: yes - - name: 'Check Helm 3.8' - command: 'which helm3.8' - - name: 'Check kubectl {{kubectl_version}}' - command: 'which kubectl' + become: true + - name: "Move Helm 3.8 bin to /usr/local/bin and set as executable" + command: "mv /tmp/helm3.8/linux-amd64/helm /usr/local/bin/helm3.8" + become: true + - name: "Check Helm 3.8" + command: "which helm3.8" + - name: "Check kubectl {{kubectl_version}}" + command: "which kubectl" - - name: 'Install Helm 3.8' + - name: "Install Helm 3.8" shell: | - echo "----> Installing helm3.8" - wget 'https://get.helm.sh/helm-v{{helm3_8_version}}-linux-amd64.tar.gz' - tar -xvf 'https://get.helm.sh/helm-v{{helm3_8_version}}-linux-amd64.tar.gz' - mv linux-amd64/helm /usr/local/bin/helm3.8 - which helm3.8 + echo "----> Installing helm3.8" + wget 'https://get.helm.sh/helm-v{{helm3_8_version}}-linux-amd64.tar.gz' + tar -xvf 'https://get.helm.sh/helm-v{{helm3_8_version}}-linux-amd64.tar.gz' + mv linux-amd64/helm /usr/local/bin/helm3.8 + which helm3.8 become: true - - - name: 'Install ChartMuseum {{chartmuseum_version}}' + - name: "Install ChartMuseum {{chartmuseum_version}}" block: - - name: 'Create directory /tmp/chartmuseum' + - name: "Create directory /tmp/chartmuseum" file: path: /tmp/chartmuseum state: directory - - name: 'Fetch tar.gz for chartmuseum' + - name: "Fetch tar.gz for chartmuseum" get_url: url: "https://get.helm.sh/chartmuseum-v{{chartmuseum_version}}-linux-amd64.tar.gz" dest: /tmp/chartmuseum - - name: 'Unarchive chartmuseum' + - name: "Unarchive chartmuseum" unarchive: src: "/tmp/chartmuseum/chartmuseum-v{{chartmuseum_version}}-linux-amd64.tar.gz" dest: /tmp/chartmuseum remote_src: true - become: yes - - name: 'Move chartmuseum bin to /usr/local/bin and set as executable' - command: 'mv /tmp/chartmuseum/linux-amd64/chartmuseum /usr/local/bin/chartmuseum' - become: yes - - name: 'Check ChartMuseum {{chartmuseum_version}}' - command: 'which chartmuseum' + become: true + - name: "Move chartmuseum bin to /usr/local/bin and set as executable" + command: "mv /tmp/chartmuseum/linux-amd64/chartmuseum /usr/local/bin/chartmuseum" + become: true + - name: "Check ChartMuseum {{chartmuseum_version}}" + command: "which chartmuseum" diff --git a/packer/provision/local-builder.yaml b/packer/provision/local-builder.yaml index a34fdb564..c12259f5d 100644 --- a/packer/provision/local-builder.yaml +++ b/packer/provision/local-builder.yaml @@ -14,8 +14,8 @@ - name: Update and upgrade apt packages apt: - upgrade: 'yes' - update_cache: yes + upgrade: "yes" + update_cache: true become: true when: ansible_distribution == 'Ubuntu' @@ -63,7 +63,7 @@ - name: Install libssl1.0-dev dep apt: name: libssl1.0-dev - update_cache: yes + update_cache: true state: fixed become: true when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04' @@ -85,7 +85,7 @@ - crudini - maven - python-ncclient - update_cache: yes + update_cache: true state: fixed become: true when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04' @@ -107,27 +107,27 @@ - crudini - maven - python3-ncclient - update_cache: yes + update_cache: true state: fixed become: true when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04' - name: Install nodejs and npm block: - - name: 'Pull latest nodejs version' + - name: "Pull latest nodejs version" shell: | curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - && sudo apt-get install -y nodejs - become: yes - - name: 'Check nodejs version' + become: true + - name: "Check nodejs version" command: node --version - - name: 'Check npm version' + - name: "Check npm version" command: npm --version when: ansible_distribution == 'Ubuntu' - name: Install npm build tools apt: name: build-essential - update_cache: yes + update_cache: true state: fixed become: true when: ansible_distribution == 'Ubuntu' @@ -136,7 +136,7 @@ apt: name: - enchant-2 - update_cache: yes + update_cache: true state: present become: true when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04' @@ -145,7 +145,7 @@ apt: name: - enchant - update_cache: yes + update_cache: true state: present become: true when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04' @@ -154,7 +154,7 @@ dnf: name: - enchant2 - update_cache: yes + update_cache: true state: present become: true when: ansible_distribution == 'CentOS' diff --git a/packer/provision/local-docker.yaml b/packer/provision/local-docker.yaml index 3d7877569..b7e1c5525 100644 --- a/packer/provision/local-docker.yaml +++ b/packer/provision/local-docker.yaml @@ -25,7 +25,8 @@ golang_checksum: sha256:d31ecae36efea5197af271ccce86ccc2baf10d2e04f20d0fb75556ecf0614dad when: "'aarch64' in ansible_architecture" - - name: 'Install Docker Compose {{docker_compose_version}}' + - name: "Install Docker Compose {{docker_compose_version}}" + # yamllint disable-line rule:line-length command: curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/{{docker_compose_version}}/docker-compose-Linux-x86_64" become: true @@ -34,16 +35,16 @@ mode: "+x" become: true - - name: 'Install GoLang {{golang_version}}' + - name: "Install GoLang {{golang_version}}" block: - - name: 'Fetch golang {{golang_version}} to /tmp/go{{golang_version}}.linux-{{host_arch}}.tar.gz' + - name: "Fetch golang {{golang_version}} to /tmp/go{{golang_version}}.linux-{{host_arch}}.tar.gz" get_url: - url: 'https://storage.googleapis.com/golang/go{{golang_version}}.linux-{{host_arch}}.tar.gz' - dest: '/tmp/go{{golang_version}}.linux-{{host_arch}}.tar.gz' - checksum: '{{golang_checksum}}' - - name: 'Install golang {{golang_version}} to /usr/local' + url: "https://storage.googleapis.com/golang/go{{golang_version}}.linux-{{host_arch}}.tar.gz" + dest: "/tmp/go{{golang_version}}.linux-{{host_arch}}.tar.gz" + checksum: "{{golang_checksum}}" + - name: "Install golang {{golang_version}} to /usr/local" unarchive: - src: '/tmp/go{{golang_version}}.linux-{{host_arch}}.tar.gz' + src: "/tmp/go{{golang_version}}.linux-{{host_arch}}.tar.gz" dest: /usr/local remote_src: true become: true @@ -69,8 +70,8 @@ - name: Update and upgrade apt packages apt: - upgrade: 'yes' - update_cache: yes + upgrade: "yes" + update_cache: true become: true when: ansible_distribution == 'Ubuntu' @@ -132,7 +133,7 @@ - crudini - maven - python-ncclient - update_cache: yes + update_cache: true state: fixed become: true when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04' @@ -154,7 +155,7 @@ - crudini - maven - python3-ncclient - update_cache: yes + update_cache: true state: fixed become: true when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04' @@ -166,7 +167,7 @@ name: - apt-transport-https - g++ - update_cache: yes + update_cache: true state: present become: true - name: add nodejs apt key @@ -178,7 +179,7 @@ apt_repository: repo: deb https://deb.nodesource.com/node_19.x {{ ansible_distribution_release }} main state: present - update_cache: yes + update_cache: true become: true - name: install nodejs apt: @@ -190,16 +191,16 @@ - name: Check nodejs and npm versions block: - - name: 'Check nodejs version' + - name: "Check nodejs version" command: node --version - - name: 'Check npm version' + - name: "Check npm version" command: npm --version when: ansible_distribution == 'Ubuntu' - name: Install npm build tools apt: name: build-essential - update_cache: yes + update_cache: true state: fixed become: true when: ansible_distribution == 'Ubuntu' @@ -227,6 +228,7 @@ when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' - name: Add Google Chrome repo + # yamllint disable-line rule:line-length copy: content="deb http://dl.google.com/linux/chrome/deb/ stable main" dest={{apt_file}} owner=root group=root mode=644 become: true when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' @@ -256,6 +258,7 @@ name: - libwxgtk3.0-0v5 become: true + # yamllint disable-line rule:line-length when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04' - name: Install Erlang dependency package libwxgtk3 for 20.04 @@ -263,12 +266,14 @@ name: - libwxgtk3.0-gtk3-0v5 become: true + # yamllint disable-line rule:line-length when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04' - name: Download and install libssl Ubuntu 20.04 apt: deb: http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.11_amd64.deb become: true + # yamllint disable-line rule:line-length when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' and ansible_distribution_version == '20.04' - name: Install Erlang @@ -277,7 +282,7 @@ become: true when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' - - name: 'Download latest rebar3 bin' + - name: "Download latest rebar3 bin" command: curl -o /usr/bin/rebar3 -L "https://s3.amazonaws.com/rebar3/rebar3" become: true when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' @@ -293,16 +298,17 @@ src: https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz dest: /usr/bin mode: 0755 - remote_src: yes + remote_src: true become: true when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' - name: Download Firefox version 55.0.3 unarchive: + # yamllint disable-line rule:line-length src: https://download-installer.cdn.mozilla.net/pub/firefox/releases/55.0.3/linux-x86_64/en-US/firefox-55.0.3.tar.bz2 dest: /opt mode: 0755 - remote_src: yes + remote_src: true become: true when: ansible_architecture == 'x86_64' and ansible_distribution == 'Ubuntu' diff --git a/packer/provision/memcached.yaml b/packer/provision/memcached.yaml index 02d3a80ee..593f98688 100644 --- a/packer/provision/memcached.yaml +++ b/packer/provision/memcached.yaml @@ -6,7 +6,7 @@ become_method: sudo tasks: - - name: 'Install Memcached' + - name: "Install Memcached" package: name: memcached state: present diff --git a/packer/provision/redis.yaml b/packer/provision/redis.yaml index b97437bdd..698665f3f 100644 --- a/packer/provision/redis.yaml +++ b/packer/provision/redis.yaml @@ -6,19 +6,19 @@ become_method: sudo tasks: - - name: 'Install Redis' + - name: "Install Redis" package: name: redis state: present become: true - - name: 'Enable service redis' + - name: "Enable service redis" service: name: redis - enabled: yes + enabled: true become: true - - name: 'Start service redis' + - name: "Start service redis" service: name: redis state: started @@ -29,6 +29,6 @@ name: - epel-release - python36 - update_cache: yes + update_cache: true state: latest become: true diff --git a/packer/templates/helm.json b/packer/templates/helm.json index ac824ced4..621c997e1 100644 --- a/packer/templates/helm.json +++ b/packer/templates/helm.json @@ -27,9 +27,7 @@ "tenant_name": "{{user `cloud_tenant`}}", "domain_name": "Default", "region": "ca-ymq-1", - "networks": [ - "{{user `cloud_network`}}" - ], + "networks": ["{{user `cloud_network`}}"], "user_data_file": "{{user `cloud_user_data`}}", "ssh_username": "{{user `ssh_user`}}", "ssh_proxy_host": "{{user `ssh_proxy_host`}}", diff --git a/packer/templates/memcached.json b/packer/templates/memcached.json index c25a564e1..c05aeb2d7 100644 --- a/packer/templates/memcached.json +++ b/packer/templates/memcached.json @@ -26,9 +26,7 @@ "tenant_name": "{{user `cloud_tenant`}}", "domain_name": "Default", "region": "ca-ymq-1", - "networks": [ - "{{user `cloud_network`}}" - ], + "networks": ["{{user `cloud_network`}}"], "user_data_file": "{{user `cloud_user_data`}}", "ssh_username": "{{user `ssh_user`}}", "ssh_proxy_host": "{{user `ssh_proxy_host`}}", diff --git a/packer/templates/redis.json b/packer/templates/redis.json index 657f10923..ae58a61f2 100644 --- a/packer/templates/redis.json +++ b/packer/templates/redis.json @@ -24,9 +24,7 @@ "tenant_name": "{{user `cloud_tenant`}}", "domain_name": "Default", "region": "ca-ymq-1", - "networks": [ - "{{user `cloud_network`}}" - ], + "networks": ["{{user `cloud_network`}}"], "user_data_file": "{{user `cloud_user_data`}}", "ssh_username": "{{user `ssh_user`}}", "ssh_proxy_host": "{{user `ssh_proxy_host`}}", -- 2.16.6