- name: httpd enabled and running ansible.builtin.service: name: httpd enabled: true state: started
- name: Test intranet web server hosts: localhost become: false tasks: - name: connect to intranet web server ansible.builtin.uri: url: http://servera.lab.example.com return_content: true status_code: 200
0│Welcome 1│————————————————————————————————————————————————————————————————————————————————————————————————————— 2│ 3│Some things you can try from here: 4│- :collections Explore available collections 5│- :config Explore the current ansible configuration 6│- :doc <plugin> Review documentation for a module or plugin 7│- :help Show the main help page 8│- :images Explore execution environment images 9│- :inventory -i <inventory> Explore an inventory 10│- :log Review the application log 11│- :lint <file or directory> Lint Ansible/YAML files (experimental) 12│- :open Open current page in the editor 13│- :replay Explore a previous run using a playbook artifact 14│- :run <playbook> -i <inventory> Run a playbook in interactive mode 15│- :settings Review the current ansible-navigator settings 16│- :quit Quit the application 17│ 18│happy automating, 19│ 20│-winston
^b/PgUp page up ^f/PgDn page down ↑↓ scroll esc back :helphelp
输入 :run intranet.yml 以交互式方式运行 playbook
1 2 3 4 5
Play name Ok Changed Unreachable Failed Skipped Ignored In progress Task count Progress 0│Enable intranet service 6 0 0 0 0 0 0 6 Complete 1│Test intranet web serve 2 0 0 0 0 0 0 2 Complete
^b/PgUp page up ^f/PgDn page down ↑↓ scroll esc back [0-9] goto :helphelp Successful
按 0 查看对应play: Enable intranet service 的详细信息
1 2 3 4 5 6 7 8 9
Result Host Number Changed Task Task action Duration 0│Ok servera.lab.example.com 0 False Gathering Facts gather_facts 1s 1│Ok servera.lab.example.com 1 False latest version of httpdansible.builtin.yum 3s 2│Ok servera.lab.example.com 2 False test html page is instaansible.builtin.copy 1s 3│Ok servera.lab.example.com 3 False firewalld enabled and ransible.builtin.service 1s 4│Ok servera.lab.example.com 4 False firewalld permits http ansible.posix.firewalld 1s 5│Ok servera.lab.example.com 5 False httpd enabled and runniansible.builtin.service 1s
^b/PgUp page up ^f/PgDn page down ↑↓ scroll esc back [0-9] goto :helphelp Successful
按 ESC 返回到主 playbook 摘要页面,然后按 1 以显示 Test intranet web server play 的详细信息。
1 2 3 4 5
Result Host Number Changed Task Task action Duration 0│Ok localhost 0 False Gathering Facts gather_facts 1s 1│Ok localhost 1 False connect to intranet web server ansible.builtin.uri 1s
^b/PgUp page up ^f/PgDn page down ↑↓ scroll esc back [0-9] goto :helphelp Successful