status_code 的状态代码范围

Range of status codes for status_code

A​​nsible 2.9.6

当我指定 status codes as a list 时,剧本运行良好。

---
- hosts: localhost
  tasks:
    - name: Create a new bitbucket repository
      uri:
        user: "{{username}}"
        password: "{{password}}"
        method: POST
        body_format: json
        body: "{{ lookup('file','create-repo.json')}}"
        return_content: yes
        status_code: [200,201,400,401,403,409,500]
        force_basic_auth: yes
        validate_certs: no
        url: "{{url}}"
      register: bitbucketResponse

    - name: show bitbucket reponse
      debug:
        msg: "{{bitbucketResponse}}"
...

我想指定一个范围(200 到 500),但我不知道它是否受支持,例如:status_code:[200:500]

可以使用range。例如

    status_code: "{{ range(200, 500, 1)|list }}"