Running ansible command on a single server when it is deployed to multiple servers

0 votes
I want to run a database migration operation at the end of a deployment process for my application. So, the problem is I want to cal this operation only once for one particular server, but ansible runs all commands on all given servers. Is there any way to do this?
Jun 13, 2018 in Ansible by Damon Salvatore
• 5,510 points
175 views

1 answer to this question.

0 votes

You can try the run_once attribute:

Example from the ansible docs:

---
# ...

  tasks:

    # ...

    - command: /opt/application/upgrade_db.py
      run_once: true

    # ...
answered Jun 13, 2018 by DareDev
• 6,810 points

Related Questions In Ansible

0 votes
1 answer
0 votes
3 answers
+1 vote
1 answer

Is it possible to append a large amount of text to a file using Ansible?

Here is concept which you can follow. blockinfile is ...READ MORE

answered Jul 30, 2018 in Ansible by Atul
• 10,240 points
2,505 views
0 votes
1 answer

Is it possible to run commands on ansible host?

If you just trying to run a ...READ MORE

answered Jan 9 in Ansible by Vijay
88 views
0 votes
1 answer
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
152 views
0 votes
1 answer

Using multiple config files using same template in a role in ansible

Go through this include_role module: tasks: - ...READ MORE

answered Jun 5, 2018 in Ansible by DareDev
• 6,810 points
535 views
0 votes
1 answer

Permission denied when running ansible playbook through jenkins

Jenkins uses it's own user to execute ...READ MORE

answered Jun 25, 2018 in Ansible by DareDev
• 6,810 points
661 views