Загрузка...

Ansible Tutorial Running Effective Tests Against Web Server Deployments

In this Tutorial with Ansible, we can easily deploy the http server but we learn to implement testing too. Testing the deployment of the HTTP server or anything really is something Ansible can and should do. Take the HTTP server: Has the correct content been delivered, are their permission or SELinux issues with the content. Dod the service start but then quickly fail. Just checking the green output of Ansible will not help you too much in proving that the http web server deployment worked. We need to connect to the service and Ansible can do this. As well as asking each node to check itself in a test, we are better to connect from a remote system, allowing checking of access from another network through firewalls and so on. So we will show how Ansible can build a list of hosts using a template and iterate through the list. Creating the text file we read the file in with "with_lines: cat text.txt". A simply awesome way to create dynamic list from the Ansible cache hostvars blog: https://www.theurbanpenguin.com/executing-tests-in-ansible/ playbook.yaml --- - name: Http deployment hosts: webservers become: true gather_facts: true tasks: - name: deploy http package: name: httpd state: present - name: start service service: name: httpd state: started enabled: true - name: deliver content copy: content: This is the web content dest: /var/www/html/index.html - name: test http hosts: localhost connection: local become: false tasks: - name: create a list of hosts from hostvars template: src: test.j2 dest: test.txt - name: test 200 uri: url: http://{{ item }} status_code: 200 with_lines: cat test.txt - name: test content uri: url: http://{{ item }} return_content: true register: web failed_when: "'This is the web content' not in web.content" with_lines: cat test.txt test.j2 {% for host in groups['webservers'] %} {{ hostvars[host]['ansible_default_ipv4']['address'] }} {% endfor %} Additionally you can find my video courses on Pluralsight: http://pluralsight.com/training/Authors/Details/andrew-mallett and take time to see my own site http://www.theurbanpenguin.com -~-~~-~~~-~~-~- Please watch: "RHCSA 9 Working With Podman Containers" https://www.youtube.com/watch?v=piwcpd_hWn0 -~-~~-~~~-~~-~-

Видео Ansible Tutorial Running Effective Tests Against Web Server Deployments автора Программистская Ценность
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять