Fix Ansible lint errors

Fixed Ansible lint errors ANSIBLE0012 and ANSIBLE0013
which address the usage of shell and command modules properly.

* When a shell/command task creates a file, it should explictly
  specify it with a 'creates' argument.
* When shell is not required, use the command module.
* If a task is not changing anything (e.g. cat <file>)
  it should be marked as "changed_when: false".

Also, fixed lines with 'ignore_error' to be 'ignore_errors'.

Change-Id: I1ef35242e2d1427d96320c47aff22e86bc035ada
changes/43/632043/3
abregman 4 years ago
parent 250c444223
commit b2a38c21cc
  1. 2
      migration/infrared/tripleo-ovn-migration/main.yml
  2. 2
      migration/infrared/tripleo-ovn-migration/roles/create-resources/tasks/main.yml
  3. 13
      migration/infrared/tripleo-ovn-migration/roles/prepare-migration/tasks/main.yml
  4. 21
      migration/migrate-to-ovn.yml
  5. 1
      migration/tripleo_environment/playbooks/roles/delete-neutron-resources/tasks/main.yml
  6. 2
      migration/tripleo_environment/playbooks/roles/tripleo-update/tasks/main.yml

@ -146,7 +146,7 @@
ovn_migration_working_dir: /home/stack/ovn_migration
- name: Copy the playbook files into ovn_migration working dir
shell: cp -rf /usr/share/ansible/networking-ovn-migration/playbooks {{ ovn_migration_working_dir }}
command: cp -rf /usr/share/ansible/networking-ovn-migration/playbooks {{ ovn_migration_working_dir }}
- name: Set the public network name (infrared deployment)
set_fact:

@ -19,6 +19,7 @@
set -o pipefail &&
{{ ovn_migration_temp_dir }}/create-resources.sh 2>&1 >
{{ ovn_migration_temp_dir }}/create-resources.sh.log
changed_when: true
- name: Generate pinger script
template:
@ -29,3 +30,4 @@
- name: Start pinger in background
shell: >
nohup {{ ovn_migration_temp_dir }}/start-pinger.sh </dev/null >/dev/null 2>&1 &
changed_when: False

@ -24,8 +24,7 @@
- deploy_file_2.stat.exists|bool
- name: Copy overcloud deploy script to overcloud-deploy-ovn.sh
shell:
cp -f {{ overcloud_deploy_script }} ~/overcloud-deploy-ovn.sh
command: cp -f {{ overcloud_deploy_script }} ~/overcloud-deploy-ovn.sh
when: infrared_deployment|bool
- name: set overcloud deploy ovn script
@ -75,7 +74,7 @@
block:
- name: Get puddle version
shell: cat containers-prepare-parameter.yaml | grep -v _tag | grep tag | awk '{print $2}'
ignore_error: True
ignore_errors: True
register: core_puddle_version
- name: Set image tag from puddle version
@ -84,7 +83,7 @@
- name: Get registry namespace
shell: cat containers-prepare-parameter.yaml | grep -v _namespace | grep namespace | awk '{print $2}'
ignore_error: True
ignore_errors: True
register: reg_ns
- name: Set registry namespace
@ -111,6 +110,8 @@
- name: Generate ovn container images
shell: |
echo "container_images:" > ~/ovn_container_images.yaml
args:
creates: ~/ovn_container_images.yaml
- name: Add ovn container images to ovn_container_images.yaml
lineinfile:
@ -125,6 +126,7 @@
- name: Generate docker images environment file
shell: |
echo "parameter_defaults:" > ~/docker-images-ovn.yaml
changed_when: False
- name: Set the local namespace
block:
@ -143,7 +145,7 @@
rm -rf /tmp/oc_plan
- name: Get the local namespace
shell: cat /tmp/_reg_namespace
command: cat /tmp/_reg_namespace
register: local_ns
- name: Set the local registry
@ -175,3 +177,4 @@
shell: |
source ~/stackrc
openstack overcloud container image upload --verbose --config-file ~/ovn_container_images.yaml
changed_when: False

@ -15,27 +15,36 @@
# only if the config value needs to be changed.
- name: Configure ovn-encap-type.
command: "ovs-vsctl set open . external_ids:ovn-encap-type=geneve"
changed_when: false
- name: Configure ovn-encap-ip.
command: "ovs-vsctl set open . external_ids:ovn-encap-ip={{ ovn_encap_ip }}"
changed_when: false
- name: Configure ovn-remote.
command: "ovs-vsctl set open . external_ids:ovn-remote=tcp:{{ ovn_db_ip }}:6642"
changed_when: false
# TODO We could discover the appropriate value for ovn-bridge-mappings based on
# the openvswitch agent configuration instead of requiring it to be configured
# in the inventory.
- name: Configure ovn-bridge-mappings.
command: "ovs-vsctl set open . external_ids:ovn-bridge-mappings={{ ovn_bridge_mappings }}"
changed_when: false
- name: Get hostname
shell: hostname -f
command: hostname -f
register: hostname
check_mode: no
changed_when: false
- name: Set host name
command: "ovs-vsctl set Open_vSwitch . external-ids:hostname={{ hostname.stdout }}"
changed_when: false
# TODO ansible has an "iptables" module, but it does not allow you specify a "rule number"
# which we require here.
- name: Open Geneve UDP port for tunneling.
command: iptables -I INPUT 10 -m state --state NEW -p udp --dport 6081 -j ACCEPT
changed_when: false
- name: Persist our iptables changes after a reboot
shell: iptables-save > /etc/sysconfig/iptables.save
args:
creates: /etc/sysconfig/iptables.save
# TODO Remove this once the metadata API is supported.
# https://bugs.launchpad.net/networking-ovn/+bug/1562132
- name: Force config drive until the metadata API is supported.
@ -65,8 +74,11 @@
- name: Open OVN database ports.
command: "iptables -I INPUT 10 -m state --state NEW -p tcp --dport {{ item }} -j ACCEPT"
with_items: [ 6641, 6642 ]
changed_when: False
- name: Persist our iptables changes after a reboot
shell: iptables-save > /etc/sysconfig/iptables.save
args:
creates: /etc/sysconfig/iptables.save
# TODO Integrate HA support for the OVN control services.
- name: Start ovn-northd and the OVN databases.
when: ovn_central is defined
@ -77,9 +89,11 @@
- name: Enable remote access to the northbound database.
command: "ovn-nbctl set-connection ptcp:6641:{{ ovn_db_ip }}"
when: ovn_central is defined
changed_when: False
- name: Enable remote access to the southbound database.
command: "ovn-sbctl set-connection ptcp:6642:{{ ovn_db_ip }}"
when: ovn_central is defined
changed_when: False
- name: Ensure the Neutron ML2 plugin is installed on neutron-api hosts.
yum:
name: python-networking-ovn
@ -140,10 +154,12 @@
msg: DATA PLANE IS NOW BEING RESTORED.
- name: Delete br-tun as it is no longer used.
command: "ovs-vsctl del-br br-tun"
changed_when: false
- name: Reset OpenFlow protocol version before ovn-controller takes over.
with_items: [ br-int, br-ex ]
command: "ovs-vsctl set Bridge {{ item }} protocols=[]"
ignore_errors: True
changed_when: false
- name: Start ovn-controller.
systemd:
name: ovn-controller
@ -161,8 +177,10 @@
- name: Schedule gateway routers by running the sync util.
when: ovn_central is defined
command: neutron-ovn-db-sync-util --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini
changed_when: false
- name: Configure node for hosting gateway routers for external connectivity.
command: "ovs-vsctl set open . external_ids:ovn-cms-options=enable-chassis-as-gw"
changed_when: false
- hosts: overcloud
remote_user: "{{ remote_user }}"
@ -173,6 +191,7 @@
# # once containers are in use on the overcloud.
- name: Delete network namespaces.
command: ip -all netns delete
changed_when: false
- hosts: controller
remote_user: "{{ remote_user }}"

@ -19,3 +19,4 @@
shell: >
{{ ovn_migration_temp_dir_del }}/delete-neutron-resources.sh 2>&1 >
{{ ovn_migration_temp_dir_del }}/delete-neutron-resources.sh.log
changed_when: true

@ -15,8 +15,10 @@
shell: >
set -o pipefail &&
{{ ovn_migration_temp_dir }}/generate-ovn-extras.sh
changed_when: False
- name: Updating the overcloud stack with OVN services
shell: >
set -o pipefail &&
{{ overcloud_ovn_deploy_script }} 2>&1 > {{ overcloud_ovn_deploy_script }}.log
changed_when: true

Loading…
Cancel
Save