Skip to content

Ansible in my pansible#111

Merged
mprahl merged 3 commits intomasterfrom
ansible_in_my_pansible
May 28, 2016
Merged

Ansible in my pansible#111
mprahl merged 3 commits intomasterfrom
ansible_in_my_pansible

Conversation

@thatarchguy
Copy link
Member

A lot going on here.

We convert the install to use Ansible instead of the bash script. This works on Vagrant and any vanilla ubuntu server. For Vagrant I have the Vagrantfile pass a provision_type that is checked to determine whether or not to install and migrate mysql.

The build_release.sh script uses fpm to create a .deb package. I manually set the depends in the deb because you cannot install packages inside of installing a package in dpkg. I didn't want to shuffle lockfiles around, so this was a natural workaround.

If you installed the package using dpkg, you have to make sure you have those depends installed manually. You can work around this by using gdebi-core or by hosting the deb in an apt repo...

... I'm looking at bintray. You can then add our apt repo using

echo "deb https://dl.bintray.com/stackfocus/deb {distribution} {components}" | sudo tee -a /etc/apt/sources.list

and just apt-get install postmaster

balling right? I just have to setup travis-ci to build the deb package and upload to bintray. I wanted to pass that by you first. Bintray can also host our docker containers and many many more.

one caveat? You need to install ansible on the target using pip, since ubuntu's ansible version is way out of date. This will be irrelevant when Ubuntu 16.04 is released this month

sudo: yes
service: name=apache2 state=restarted enabled=yes

- name: Ensure apache is reloaded
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you reloading when it's restarted just above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because apache2 is fickle :P

@thatarchguy thatarchguy changed the title [WIP] Ansible in my pansible Ansible in my pansible Apr 15, 2016
@thatarchguy
Copy link
Member Author

What's the status on this?

@mprahl
Copy link
Member

mprahl commented Apr 30, 2016

@thatarchguy you were supposed to have Vagrant run without ansible needing to be installed on the host system.

@thatarchguy
Copy link
Member Author

@PrahlM93 Yeah...check the last commit...
1b98f64

@mprahl
Copy link
Member

mprahl commented May 2, 2016

Looks good. I can't test it until next Monday cause I'm in France until Sunday evening. If you're confident in it, we can merge. Otherwise we can wait for when I get back.

@thatarchguy
Copy link
Member Author

Enjoy your vacation :D

Vagrantfile Outdated
'--extra-vars="remote_user=vagrant"',
'--extra-vars="provision_type=dev"'
]
# I don't know why, but extra_vars doesn't work with ansible_local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we omit the one on line 34 then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ansible.extra_vars is the proper way to do it for vagrant. The problem is that doesn't work for the ansible-local provisioner for some reason, which is what I converted it to use. The raw_arguments is a workaround. I don't like it, which is why I left both it in there. Having both still works with either ansible-local or ansible provisioner.
ansible-local or ansible provisioner.

@mprahl
Copy link
Member

mprahl commented May 11, 2016

@thatarchguy, I'm getting an Internal Server Error when running this via Vagrant. I'll have to look later to see what's causing it.

@mprahl
Copy link
Member

mprahl commented May 14, 2016

@thatarchguy, I fixed the internal server error by removing the current migration scripts if present when in the dev provisioning type. I also had an issue destroying the VM since I didn't have ansible installed on my client. I fixed that by entirely running ansible on the guest through a shell script. I also fixed some deprecation warnings on sudo.

Check out the commit and let me know what you think.

@@ -0,0 +1,3 @@
---
remote_user: "ubuntu"
Copy link
Member

@mprahl mprahl May 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is defaulting to a non-existent user by default. How will ansible run a resource that uses this as an argument when ansible is being run by a package where you can't pass arguments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thatarchguy, what are your thoughts on this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a step in the ansible playbook create a user defined by that variable and go from there? That's doable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's an idea. Like create a PostMaster user?

What other options are there? Can we just use built-in users instead?

@thatarchguy
Copy link
Member Author

I also had an issue destroying the VM since I didn't have ansible installed on my client. I fixed that by entirely running ansible on the guest through a shell script.

Errrr you shouldn't need ansible on your host at all. It was also being installed into the guest by vagrant automagically. https://www.vagrantup.com/docs/provisioning/ansible_local.html

The reason I still used sudo and not become was because I was running into issues with it on my other projects (ansible/ansible#14022)

thatarchguy and others added 2 commits May 17, 2016 20:34
Added travis fpm build and deploy to bintray

Signed-off-by: Kevin <kevin@stealsyour.pw>
* Stops using ansible provisioner and runs ansible entirely on the guest
using Vagrant
* Fixes issue where migration scripts were still present causing the
database to not be created
* Replaces sudo with becomes to avoid deprecation warnings
@mprahl mprahl force-pushed the ansible_in_my_pansible branch from ed42ac2 to d67702a Compare May 18, 2016 00:37
Creates PostMaster service account user for file ownership

Signed-off-by: Kevin <kevin@stealsyour.pw>
@mprahl mprahl force-pushed the ansible_in_my_pansible branch from df63a97 to a620637 Compare May 28, 2016 18:28
@mprahl
Copy link
Member

mprahl commented May 28, 2016

@thatarchguy, LGTM
LGTM

@mprahl mprahl merged commit babae75 into master May 28, 2016
@mprahl mprahl deleted the ansible_in_my_pansible branch June 21, 2016 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants