Deployment with Ansible
We have covered the most fundamental features of Ansible. Let's now forget, just for a little while, about Docker and configure a complete deployment step using Ansible. We will run the calculator service on one server and the Redis service on the second server.
Installing Redis
We can specify a play in the new playbook. Let's create the playbook.yml
file with the following content:
--- - hosts: web1 become: yes become_method: sudo tasks: - name: install Redis apt: name: redis-server state: present - name: start Redis service: name: redis-server state: started - name: copy Redis configuration copy: src: redis.conf dest: /etc/redis/redis.conf notify: restart Redis handlers: - name: restart Redis service: name: redis-server state: restarted
The configuration is executed on one server web1
. It installs the redis-server
package, copies the Redis configuration, and starts Redis. Note that each...