From: Sébastien Han Date: Thu, 1 Nov 2018 11:50:31 +0000 (+0100) Subject: lint: do not use local_action X-Git-Tag: v4.0.0beta1~258 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=094ae8baf1228cebaf25bb3706a1e26e275d5528;p=ceph-ansible.git lint: do not use local_action Use delegate_to: localhost instead. Signed-off-by: Sébastien Han --- diff --git a/roles/ceph-common/tasks/facts_mon_fsid.yml b/roles/ceph-common/tasks/facts_mon_fsid.yml index 157c384f3..a5023caba 100644 --- a/roles/ceph-common/tasks/facts_mon_fsid.yml +++ b/roles/ceph-common/tasks/facts_mon_fsid.yml @@ -30,9 +30,8 @@ - test_initial_monitor_keyring.rc != 0 - name: write initial mon keyring in {{ fetch_directory }}/monitor_keyring.conf if it doesn't exist - local_action: - module: shell - echo {{ monitor_keyring.stdout }} | tee {{ fetch_directory }}/monitor_keyring.conf + shell: "echo {{ monitor_keyring.stdout }} | tee {{ fetch_directory }}/monitor_keyring.conf" + delegate_to: localhost become: false when: - test_initial_monitor_keyring.rc == 0 diff --git a/roles/ceph-config/tasks/main.yml b/roles/ceph-config/tasks/main.yml index 8130c922e..0591fda7e 100644 --- a/roles/ceph-config/tasks/main.yml +++ b/roles/ceph-config/tasks/main.yml @@ -95,18 +95,19 @@ - name: "ensure fetch directory exists" run_once: true become: false - local_action: - module: file + file: path: "{{ fetch_directory }}/{{ fsid }}/etc/ceph" state: directory mode: "0755" + delegate_to: localhost when: - ceph_conf_local - name: "generate {{ cluster }}.conf configuration file locally" - local_action: config_template + config_template: become: false run_once: true + delegate_to: localhost args: src: "ceph.conf.j2" dest: "{{ fetch_directory }}/{{ fsid }}/etc/ceph/{{ cluster }}.conf" @@ -125,10 +126,10 @@ # we are not population kv_store with default ceph.conf AND there at least 1 nfs in nfs group AND host is the first nfs - block: - name: create a local fetch directory if it does not exist - local_action: - module: file + file: path: "{{ fetch_directory }}" state: directory + delegate_to: localhost changed_when: false become: false run_once: true @@ -141,20 +142,20 @@ and (inventory_hostname == groups.get(nfs_group_name, [])[0]))) - name: generate cluster uuid - local_action: - module: shell - python -c 'import uuid; print(str(uuid.uuid4()))' | tee {{ fetch_directory }}/ceph_cluster_uuid.conf + shell: python -c 'import uuid; print(str(uuid.uuid4()))' | tee {{ fetch_directory }}/ceph_cluster_uuid.conf + args: creates: "{{ fetch_directory }}/ceph_cluster_uuid.conf" + delegate_to: localhost register: cluster_uuid become: false when: - generate_fsid - name: read cluster uuid if it already exists - local_action: - module: command - cat {{ fetch_directory }}/ceph_cluster_uuid.conf + command: "cat {{ fetch_directory }}/ceph_cluster_uuid.conf" + args: removes: "{{ fetch_directory }}/ceph_cluster_uuid.conf" + delegate_to: localhost changed_when: false register: cluster_uuid check_mode: no diff --git a/roles/ceph-defaults/tasks/facts.yml b/roles/ceph-defaults/tasks/facts.yml index 168680224..ef8c5f94b 100644 --- a/roles/ceph-defaults/tasks/facts.yml +++ b/roles/ceph-defaults/tasks/facts.yml @@ -45,9 +45,9 @@ # We want this check to be run only on the first node - name: check if {{ fetch_directory }} directory exists - local_action: - module: stat + stat: path: "{{ fetch_directory }}/monitor_keyring.conf" + delegate_to: localhost become: false register: monitor_keyring_conf run_once: true @@ -62,10 +62,10 @@ - rolling_update or groups.get(mon_group_name, []) | length == 0 - name: create a local fetch directory if it does not exist - local_action: - module: file + file: path: "{{ fetch_directory }}" state: directory + delegate_to: localhost changed_when: false become: false when: @@ -90,30 +90,30 @@ ceph_release: "{{ ceph_stable_release }}" - name: generate cluster fsid - local_action: - module: shell - python -c 'import uuid; print(str(uuid.uuid4()))' | tee {{ fetch_directory }}/ceph_cluster_uuid.conf + shell: python -c 'import uuid; print(str(uuid.uuid4()))' | tee {{ fetch_directory }}/ceph_cluster_uuid.conf + args: creates: "{{ fetch_directory }}/ceph_cluster_uuid.conf" register: cluster_uuid + delegate_to: localhost become: false when: - generate_fsid - ceph_current_status.fsid is undefined - name: reuse cluster fsid when cluster is already running - local_action: - module: shell - echo {{ fsid }} | tee {{ fetch_directory }}/ceph_cluster_uuid.conf + shell: echo {{ fsid }} | tee {{ fetch_directory }}/ceph_cluster_uuid.conf + args: creates: "{{ fetch_directory }}/ceph_cluster_uuid.conf" + delegate_to: localhost become: false when: - ceph_current_status.fsid is defined - name: read cluster fsid if it already exists - local_action: - module: command - cat {{ fetch_directory }}/ceph_cluster_uuid.conf + command: cat {{ fetch_directory }}/ceph_cluster_uuid.conf + args: removes: "{{ fetch_directory }}/ceph_cluster_uuid.conf" + delegate_to: localhost changed_when: false register: cluster_uuid become: false diff --git a/roles/ceph-docker-common/tasks/fetch_image.yml b/roles/ceph-docker-common/tasks/fetch_image.yml index 4f3e5c8c8..1b6347457 100644 --- a/roles/ceph-docker-common/tasks/fetch_image.yml +++ b/roles/ceph-docker-common/tasks/fetch_image.yml @@ -276,9 +276,10 @@ - ceph_nfs_image_repodigest_before_pulling != image_repodigest_after_pulling - name: export local ceph dev image - local_action: - module: command - docker save -o "/tmp/{{ ceph_docker_username }}-{{ ceph_docker_imagename }}-{{ ceph_docker_image_tag }}.tar" "{{ ceph_docker_username }}/{{ ceph_docker_imagename }}:{{ ceph_docker_image_tag }}" + command: > + docker save -o "/tmp/{{ ceph_docker_username }}-{{ ceph_docker_imagename }}-{{ ceph_docker_image_tag }}.tar" + "{{ ceph_docker_username }}/{{ ceph_docker_imagename }}:{{ ceph_docker_image_tag }}" + delegate_to: localhost when: - (ceph_docker_dev_image is defined and ceph_docker_dev_image) run_once: true diff --git a/roles/ceph-docker-common/tasks/stat_ceph_files.yml b/roles/ceph-docker-common/tasks/stat_ceph_files.yml index 16f4d62ea..aa732cc12 100644 --- a/roles/ceph-docker-common/tasks/stat_ceph_files.yml +++ b/roles/ceph-docker-common/tasks/stat_ceph_files.yml @@ -28,9 +28,9 @@ when: groups.get(mgr_group_name, []) | length > 0 - name: stat for ceph config and keys - local_action: - module: stat + stat: path: "{{ fetch_directory }}/{{ fsid }}/{{ item }}" + delegate_to: localhost with_items: "{{ ceph_config_keys }}" changed_when: false become: false diff --git a/roles/ceph-iscsi-gw/tasks/deploy_ssl_keys.yml b/roles/ceph-iscsi-gw/tasks/deploy_ssl_keys.yml index f4979f2cb..afd474db5 100644 --- a/roles/ceph-iscsi-gw/tasks/deploy_ssl_keys.yml +++ b/roles/ceph-iscsi-gw/tasks/deploy_ssl_keys.yml @@ -8,9 +8,9 @@ - "iscsi-gateway-pub.key" - name: stat for crt file(s) - local_action: - module: stat + stat: path: "{{ fetch_directory }}/{{ fsid }}/{{ item }}" + delegate_to: localhost with_items: "{{ crt_files }}" changed_when: false failed_when: false @@ -18,16 +18,21 @@ register: crt_files_exist - name: create ssl crt/key files - local_action: - module: command openssl req -newkey rsa:2048 -nodes -keyout {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.key -x509 -days 365 -out {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.crt -subj "/C=US/ST=./L=./O=RedHat/OU=Linux/CN={{ ansible_hostname }}" + command: > + openssl req -newkey rsa:2048 -nodes -keyout {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.key + -x509 -days 365 -out {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.crt + -subj "/C=US/ST=./L=./O=RedHat/OU=Linux/CN={{ ansible_hostname }}" + delegate_to: localhost run_once: True with_items: "{{ crt_files_exist.results }}" when: - item.stat.exists == false - name: create pem - local_action: - module: shell cat {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.crt {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.key > {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.pem + shell: > + cat {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.crt + {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.key > {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.pem + delegate_to: localhost run_once: True register: pem with_items: "{{ crt_files_exist.results }}" @@ -35,8 +40,10 @@ - item.stat.exists == false - name: create public key from pem - local_action: - module: shell openssl x509 -inform pem -in {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.pem -pubkey -noout > {{ fetch_directory }}/{{ fsid }}/iscsi-gateway-pub.key + shell: > + openssl x509 -inform pem -in {{ fetch_directory }}/{{ fsid }}/iscsi-gateway.pem + -pubkey -noout > {{ fetch_directory }}/{{ fsid }}/iscsi-gateway-pub.key + delegate_to: localhost run_once: True when: - pem.changed diff --git a/roles/ceph-mds/tasks/containerized.yml b/roles/ceph-mds/tasks/containerized.yml index 55b34fbd5..9fc286581 100644 --- a/roles/ceph-mds/tasks/containerized.yml +++ b/roles/ceph-mds/tasks/containerized.yml @@ -22,9 +22,9 @@ - copy_admin_key - name: stat for ceph config and keys - local_action: - module: stat + stat: path: "{{ fetch_directory }}/{{ fsid }}/{{ item }}" + delegate_to: localhost with_items: "{{ ceph_config_keys }}" changed_when: false become: false diff --git a/roles/ceph-mon/tasks/deploy_monitors.yml b/roles/ceph-mon/tasks/deploy_monitors.yml index d792db1b4..04b29ddd9 100644 --- a/roles/ceph-mon/tasks/deploy_monitors.yml +++ b/roles/ceph-mon/tasks/deploy_monitors.yml @@ -1,18 +1,22 @@ --- - name: generate monitor initial keyring - local_action: - module: shell - python -c "import os ; import struct ; import time; import base64 ; key = os.urandom(16) ; header = struct.pack(' + python -c "import os ; import struct ; + import time; import base64 ; key = os.urandom(16) ; + header = struct.pack('