<p>If you have ssh access from the Jenkins machine to the HAProxy machine, you could run an Ansible task:</p>

<p><code>ansible -i ha-inventory.ini ha-servers -m service -a name=haproxy state=restarted</code></p>

<p>Of course you could also have Jenkins do a simple ssh :</p>

<p><code>for server in ${server_list} ; do ssh server 'sudo service haproxy restart' ; done</code></p>

<p>For both of these, you would need </p>

<ul>
<li>ssh keys set up between Jenkins and the HAProxy servers</li>
<li>sudo rights for restarting the service (at least) for the connecting user (probably <code>jenkins</code>)</li>
</ul>

CC BY-SA 4.0
2019-10-24T07:35:35.087Z
2019-10-24T07:35:35.087Z
Bruce Becker
<p>I have a HAProxy server setup in Azure Linux Machine. How can I run a HAProxy start/stop command from Jenkins to multiple Linux server? </p>

<jenkins><linux>
Run command from Jenkins to Linux Server
ankit thakkar
# Run command from Jenkins to Linux Server

(Asked by: username_0 on 2019-10-24)

I have a HAProxy server setup in Azure Linux Machine. How can I run a HAProxy start/stop command from Jenkins to multiple Linux server?

**Tags:** jenkins, linux


---

## 1 answers

### Answer by username_1 on 2019-10-24. Score: 1

If you have ssh access from the Jenkins machine to the HAProxy machine, you could run an Ansible task:

`ansible -i ha-inventory.ini ha-servers -m service -a name=haproxy state=restarted`

Of course you could also have Jenkins do a simple ssh :

`for server in ${server_list} ; do ssh server 'sudo service haproxy restart' ; done`

For both of these, you would need

* ssh keys set up between Jenkins and the HAProxy servers
* sudo rights for restarting the service (at least) for the connecting user (probably `jenkins`)


---

