参考: https://docs.ansible.com/ansible/2.9/modules/uri_module.html https://www.codenong.com/51214785/ https://blog.csdn.net/byygyy/article/details/105259356
1.调用jenkins pipeline示例:
1.1 by shell curl:
curl -X POST http://192.168.3.21:8080/job/lhh_pub/job/hello_world/buildWithParameters --user robin:11aa405306748aeaac00767d9837a051c2 --data env_name=DEV2
1.2 by ansible:
- name: call jenkins pipeline
uri:
url: 'http://192.168.3.21:8080/job/lhh_pub/job/hello_world/buildWithParameters'
user: robin
password: 11aa405306748aeaac00767d9837a051c2
force_basic_auth: yes
method: POST
status_code: 201
body: "env_name=DEV2"
or
- name: call jenkins pipeline 1st way
shell: "curl -X POST http://192.168.3.21:8080/job/lhh_pub/job/hello_world/buildWithParameters --user robin:11aa405306748aeaac00767d9837a051c2 --data env_name=DEV2"
2.调用外部API with header:
- name: Connect to website using a previously stored cookie
uri:
url: https://your.form.based.auth.example.com/dashboard.php
method: POST
return_content: yes
headers:
Cookie: "{{ login.set_cookie }}"
3.调用ansible tower by API
待续
|