AWX - deploy nginx.conf updates from git

149 views
Skip to first unread message

steve flitcroft

unread,
Oct 30, 2013, 5:21:52 AM10/30/13
to ansible...@googlegroups.com
Hi, I am new to awx and ansible. Could someone show me the best way to pull the latest nginx conf file from a git repo and deploy across a cluster of nginx boxes. Do I have to clone the repo to the ansible server then do a copy task to all hosts and a notify task to restart nginx? Can I do this in a single job template? Any examples welcome.

Thanks

Timothy Gerla

unread,
Oct 30, 2013, 11:35:25 AM10/30/13
to ansible-project
You could do this one of two ways, both with a single playbook. The first method would use two plays, one local play to check out the configuration once, and a second play that operates on the nginx hosts and copies:

(I didn't test this playbook, FYI)

---
- hosts: local
  connection: local
  tasks:

  - name: git clone to the ansible server
    git: repo=git://foosball.example.org/path/to/repo.git dest=/tmp/checkout

- hosts: nginx-hosts
  tasks:

  - name: copy files to target hosts
    copy: src=/tmp/checkout/nginx.conf dest=/etc/nginx/


Another way would be to just run the git clone on the target boxes, and move the files into place:

---
- hosts: nginx
  tasks:

  - name: git clone to the target servers
    git: repo=git://foosball.example.org/path/to/repo.git dest=/tmp/checkout

  - name: copy the nginx config file into place
    command: cp /tmp/checkout/nginx.conf /etc/nginx/nginx.conf creates=/etc/nginx.conf


Something like that should do the trick.

-Tim

On Wed, Oct 30, 2013 at 2:21 AM, steve flitcroft <steve.f...@gmail.com> wrote:
Hi, I am new to awx and ansible. Could someone show me the best way to pull the latest nginx conf file from a git repo and deploy across a cluster of nginx boxes. Do I have to clone the repo to the ansible server then do a copy task to all hosts and a notify task to restart nginx? Can I do this in a single job template? Any examples welcome.

Thanks

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--

James Cammarata

unread,
Oct 30, 2013, 1:41:23 PM10/30/13
to ansible...@googlegroups.com
The only other suggestion I had would be, if the git repo mirrors the /etc/nginx/ directory, you could just do the git checkout to that directory:

---
- hosts: nginx
  tasks:
  - name: clone nginx config
    git: repo=git://foosball.example.org/path/to/repo.git dest=/etc/nginx

That way it's just one step. You'd probably also want to add a handler notification to that, so nginx would be restarted if the git repository were updated.
James Cammarata <jcamm...@ansibleworks.com>
Sr. Software Engineer, AnsibleWorks, Inc.
http://www.ansibleworks.com/

jagruti belani

unread,
Dec 6, 2022, 6:01:56 PM12/6/22
to Ansible Project
How to replace /etc/nginx/nginx.conf inside AWX ?

I want o change the Timeout uwsgi_read_timeout 120s; to uwsgi_read_timeout 600s;
please suggest.
Reply all
Reply to author
Forward
0 new messages