Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ansible TypeError:必须是字符串或缓冲区,而不是列表_Ansible_Ansible 2.x - Fatal编程技术网

Ansible TypeError:必须是字符串或缓冲区,而不是列表

Ansible TypeError:必须是字符串或缓冲区,而不是列表,ansible,ansible-2.x,Ansible,Ansible 2.x,下面的任务失败,必须是字符串或缓冲区,而不是列表,当我在shell上使用相同的循环时,输出打印字符串,所以不确定哪里出错。我还使用了循环,它也给出了相同的输出 - name: Provide Ambari cluster user role to users in file {{ cluster_user_group_file }} uri: url: "http://{{ ansible_fqdn }}:8080/api/v1/clusters/{{ cluster_name

下面的任务失败,必须是字符串或缓冲区,而不是列表,当我在shell上使用相同的循环时,输出打印字符串,所以不确定哪里出错。我还使用了
循环
,它也给出了相同的输出

- name: Provide Ambari cluster user role to users in file {{ cluster_user_group_file }}
  uri:
      url: "http://{{ ansible_fqdn }}:8080/api/v1/clusters/{{ cluster_name }}/privileges"
      method: POST
      force_basic_auth: yes
      user: "{{ ambari_admin_user }}"
      password: "{{ ambari_admin_password }}"
      headers: '{"X-Requested-By":"ambari"}'
      body: "[{\"PrivilegeInfo\":{\"permission_name\":\"CLUSTER.USER\",\"principal_name\":\"{{ item }}\",\"principal_type\":\"GROUP\"}}]"
      status_code: 200,201,202,409
      timeout: 60
      return_content: no
  with_items: "{{ lookup('file', '{{ cluster_user_group_file }}').split(',') }}"

通过将
添加到_json
并设置
body\u格式:raw

- name: Provide Ambari cluster user role to users in file {{ cluster_user_group_file }}
  uri:
      url: "http://{{ ansible_fqdn }}:8080/api/v1/clusters/{{ cluster_name }}/privileges"
      method: POST
      force_basic_auth: yes
      user: "{{ ambari_admin_user }}"
      password: "{{ ambari_admin_password }}"
      headers: '{"X-Requested-By":"ambari"}'
      body: "[{\"PrivilegeInfo\":{\"permission_name\":\"CLUSTER.USER\",\"principal_name\":\"{{ item }}\",\"principal_type\":\"GROUP\"}}]|to_json"
      body_format: raw
      status_code: 200,201,202,409
      timeout: 60
      return_content: no
  with_items: "{{ lookup('file', '{{ cluster_user_group_file }}').split(',') }}"

通过将
添加到_json
并设置
body\u格式:raw

- name: Provide Ambari cluster user role to users in file {{ cluster_user_group_file }}
  uri:
      url: "http://{{ ansible_fqdn }}:8080/api/v1/clusters/{{ cluster_name }}/privileges"
      method: POST
      force_basic_auth: yes
      user: "{{ ambari_admin_user }}"
      password: "{{ ambari_admin_password }}"
      headers: '{"X-Requested-By":"ambari"}'
      body: "[{\"PrivilegeInfo\":{\"permission_name\":\"CLUSTER.USER\",\"principal_name\":\"{{ item }}\",\"principal_type\":\"GROUP\"}}]|to_json"
      body_format: raw
      status_code: 200,201,202,409
      timeout: 60
      return_content: no
  with_items: "{{ lookup('file', '{{ cluster_user_group_file }}').split(',') }}"