# Automate Discourse Docker with Ansible

**URL:** https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150
**Category:** Self-hosting
**Tags:** unsupported-install, hosting
**Created:** [7월 31, 2017, 8:54오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150 "2017-07-31T08:54:17Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![joebew42](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@joebew42](https://meta.discourse.org/u/joebew42)
#### Post date: [7월 31, 2017, 8:54오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/1 "2017-07-31T08:54:17Z")

</div>

Hello folks,

we would like to announce a stable version of [Ansible Discourse](https://github.com/xpeppers/ansible-discourse), it is an ansible playbook that helps you to confgure and provision the [Discourse Docker](https://github.com/discourse/discourse_docker) easily.

I hope that this project can be useful for everyone who wants to install and configure a new Discourse.

Do you have any feedback?

**Contributors are welcome** 🤗

At the moment we wrote two scripts (`scripts/`) that can be used to run the provisioning on a local vagrant machine or AWS. It could be useful to add support for other providers, like DigitalOcean, Google Cloud, and other.

---

<div class="post-metadata">

### Author: ![Muiran](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/muiran/32/73797_2.png) [@Muiran](https://meta.discourse.org/u/Muiran)
#### Post date: [7월 31, 2017, 5:07오후 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/2 "2017-07-31T17:07:54Z")

</div>

I would like to experiment with it on [GANDI.net](http://GANDI.net) is tha’s not too much trouble.

Thanks

---

<div class="post-metadata">

### Author: ![treb0r](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@treb0r](https://meta.discourse.org/u/treb0r)
#### Post date: [8월 3, 2017, 8:06오후 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/3 "2017-08-03T20:06:26Z")

</div>

This is exactly what I’m looking for.

I’ve been using Ansible a lot thanks to the fantastic [Roots](https://roots.io/) [Trellis](https://roots.io/trellis/) for WordPress, and I’ve come to realise the benefits of using automated provisions and deploys with the ability to store the configs in git.

I look after several discourse instances and this approach will allow me to properly standardise everything.

I’m going to have a play with this and report back.

Thanks!

---

<div class="post-metadata">

### Author: ![treb0r](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@treb0r](https://meta.discourse.org/u/treb0r)
#### Post date: [8월 3, 2017, 8:12오후 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/4 "2017-08-03T20:12:33Z")

</div>

I’m also going to see if I can get this working with LXD.

---

<div class="post-metadata">

### Author: ![vesper8](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@vesper8](https://meta.discourse.org/u/vesper8)
#### Post date: [10월 4, 2018, 1:44오후 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/5 "2018-10-04T13:44:27Z")

</div>

This is great! But why is it exclusive to AWS? What if I would like to use Discourse Docker and Ansible to provision this on another VPS such as Linode, Vultr or DigitalOcean?

Any chance to make this a little more flexible? Is there a hard requirement on AWS? I see that AWS-CLI is listed as a requirement

---

<div class="post-metadata">

### Author: ![joebew42](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@joebew42](https://meta.discourse.org/u/joebew42)
#### Post date: [10월 4, 2018, 2:12오후 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/6 "2018-10-04T14:12:02Z")

</div>

Hi @vesper8, take a look at the [Provisioning](https://github.com/xpeppers/ansible-discourse#provisioning) section. As you will see there, you can easily run the provision against a local host (like vagrant), and of course, it will be very easy to adapt the script to make it works against other environments, like DigitalOcean or other.

---

<div class="post-metadata">

### Author: ![ahmed\_alamiry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ahmed_alamiry/32/198190_2.png) [@ahmed\_alamiry](https://meta.discourse.org/u/ahmed_alamiry)
#### Post date: [1월 29, 2019, 5:56오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/7 "2019-01-29T05:56:49Z")

</div>

Have you been able to skip the registration/after installation wizard. I am trying to make an ansible role to install discourse and skip any GUI configuration such as register or import custom theme. it been days looking for a way

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [1월 29, 2019, 6:25오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/8 "2019-01-29T06:25:21Z")

</div>

The registration wizard will not be shown if there is an existing admin user. So just create such a user and you’re good.

---

<div class="post-metadata">

### Author: ![ahmed\_alamiry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ahmed_alamiry/32/198190_2.png) [@ahmed\_alamiry](https://meta.discourse.org/u/ahmed_alamiry)
#### Post date: [1월 30, 2019, 8:44오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/9 "2019-01-30T08:44:57Z")

</div>

Thank you, it worked for me using rake admin:create,

Now, I am trying to add this part under RUN: in the app.yml

```
 - exec:rails r "u = User.create!(username: '{{ discourse_developer_username }}', email: '{{ discourse_developer_emails }}', password: ' {{ discourse_developer_password }}', admin: true)"

```

but it fails, even when I uncomment:

```
- exec: rails r "SiteSetting.notification_email='discourse@example.com'"

```

so how to run a rails command with out going through:

```
cd /var/discourse 
./launcher enter app
rails r "......." which it works 

```

and one more question, how to import theme through command line.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [1월 30, 2019, 1:12오후 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/10 "2019-01-30T13:12:33Z")

</div>

One solution would be to restore a backup with the user and theme you want.

---

<div class="post-metadata">

### Author: ![ahmed\_alamiry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ahmed_alamiry/32/198190_2.png) [@ahmed\_alamiry](https://meta.discourse.org/u/ahmed_alamiry)
#### Post date: [2월 5, 2019, 12:13오후 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/12 "2019-02-05T12:13:39Z")

</div>

when I added

`exec: cd /var/www/discourse && rails r "SiteSetting.notification_email= 'discourse@test.kfupm.edu.sa'"`

worked!!!

the issue was when I bootstrap the container it return an exception because of ‘:’ used in the command,  
to solve this I put the command in a file.rb and in the custom command section I added

`exec: cd /var/www/discourse && rails r file.rb`

of course you need to copy the file.rb into the container.

---

<div class="post-metadata">

### Author: ![Muthukkumar](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@Muthukkumar](https://meta.discourse.org/u/Muthukkumar)
#### Post date: [3월 5, 2019, 5:44오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/13 "2019-03-05T05:44:49Z")

</div>

Hi @ahmed_alamiry I have added the same command in app.yml custom command section but I am getting the below error. If you don’t mind could you please guide me.

```
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && rails r file.rb failed with return #<Process::Status: pid 5317 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params "cd /var/www/discourse && rails r file.rb"

```

Note : I have tried with placed the file under "/var/discourse/container# " then place inside the container “/var/www/discourse/” but both the time I got the same error.

Please guide me to configure this, Many thanks in advance.

---

<div class="post-metadata">

### Author: ![ahmed\_alamiry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ahmed_alamiry/32/198190_2.png) [@ahmed\_alamiry](https://meta.discourse.org/u/ahmed_alamiry)
#### Post date: [3월 5, 2019, 7:23오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/14 "2019-03-05T07:23:00Z")

</div>

@Muthukkumar what inside file.rb ?  
Place the file.rb in /var/discourse/shared/standalone (or what ever path in the volume section).  
In app.yml under run add:

- exec: cp /shared/file.rb /var/www/discourse
- exec: cd /var/www/discourse && rails r file.rb

---

<div class="post-metadata">

### Author: ![Muthukkumar](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@Muthukkumar](https://meta.discourse.org/u/Muthukkumar)
#### Post date: [3월 5, 2019, 8:31오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/15 "2019-03-05T08:31:05Z")

</div>

Hi @ahmed_alamiry, Thanks a lot for the quick response, below is the details.

file.rb  
rails r “u = User.create!(username: ‘{{ Muthukkumar }}’, email: ‘{{ [muthukkumar@abc.net](mailto:muthukkumar@abc.net) }}’, password: ’ {{ password123 }}', admin: true)”

for me this changes are working again I am getting the discourse wizard setup.

---

<div class="post-metadata">

### Author: ![ahmed\_alamiry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ahmed_alamiry/32/198190_2.png) [@ahmed\_alamiry](https://meta.discourse.org/u/ahmed_alamiry)
#### Post date: [3월 5, 2019, 10:42오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/16 "2019-03-05T10:42:24Z")

</div>

the account created but not activated.  
you missing "u.activate "

---

<div class="post-metadata">

### Author: ![Muthukkumar](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@Muthukkumar](https://meta.discourse.org/u/Muthukkumar)
#### Post date: [3월 5, 2019, 10:44오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/17 "2019-03-05T10:44:43Z")

</div>

So my file.rb should be like this ?

rails r “u = User.create!(username: ‘{{ Muthukkumar }}’, email: ‘{{ [muthukkumar@abc.net](mailto:muthukkumar@abc.net) }}’, password: ’ {{ mypin }}', admin: true)”  
rails r “u.activate”

---

<div class="post-metadata">

### Author: ![ahmed\_alamiry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ahmed_alamiry/32/198190_2.png) [@ahmed\_alamiry](https://meta.discourse.org/u/ahmed_alamiry)
#### Post date: [3월 5, 2019, 10:47오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/18 "2019-03-05T10:47:55Z")

</div>

**no, file.rb content:**  
u = User.create!(username: ‘{{ Muthukkumar }}’, email: ‘{{ [[muthukkumar@abc.net](mailto:muthukkumar@abc.net)] }}’, password: ’ {{ password }}’, admin: true)”; u.activate

**Then:**  
rails r file.rb

Notice the “;”.

---

<div class="post-metadata">

### Author: ![Muthukkumar](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@Muthukkumar](https://meta.discourse.org/u/Muthukkumar)
#### Post date: [3월 5, 2019, 10:54오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/19 "2019-03-05T10:54:39Z")

</div>

@ahmed_alamiry yes got it let me try this.

---

<div class="post-metadata">

### Author: ![ElijahLynn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijahlynn/32/196162_2.png) [@ElijahLynn](https://meta.discourse.org/u/ElijahLynn)
#### Post date: [10월 5, 2020, 9:49오후 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/20 "2020-10-05T21:49:25Z")

</div>

이 링크는 이제 Ansible이나 플레이북에 대한 언급 없이 Cloudformation Discord로 리디렉션됩니다. Ansible Discord 플레이북이 이제 중단된 건가요? 그렇다면 그 \_이유\_에 대해 좀 더 자세히 설명해 주실 수 있나요?

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [10월 6, 2020, 2:05오전 UTC](https://meta.discourse.org/t/automate-discourse-docker-with-ansible/67150/21 "2020-10-06T02:05:55Z")

</div>

이것은 #unsupported-install 구성이라는 점에 유의하세요. 따라서 누군가가 Ansible과 함께 `discourse-docker`를 사용하기로 진행하더라도 여기서는 지원되지 않습니다.
