Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Remove vagrant assets and restructure
Browse files Browse the repository at this point in the history
Previously, the example playbooks (and docs) were coupled with vagrant
usage. This PR removes the vagrant assets, and revises the examples and
documentation to be applicable for those using ansible directly (without
Vagrant). As a bonus, the example playbooks and variables are symlinked
to molecule, so the examples are tested by travis for PRs against this
repository.

https://pulp.plan.io/issues/4325
re: #4325
  • Loading branch information
asmacdo committed Feb 26, 2019
1 parent e0b9cc8 commit 09c2fd2
Show file tree
Hide file tree
Showing 26 changed files with 116 additions and 312 deletions.
178 changes: 73 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
ansible-pulp3
=============
Pulp 3 Ansible installer
========================

Pulp 3 Ansible installer.

The Pulp 3 Ansible installer consists of several roles. Each role installs and
configures a component of Pulp. For example, the `pulp3-postgresql` role
installs and configures PostgreSQL. The roles are not currently available on
Ansible Galaxy. To run the Pulp 3 Ansible installer, the
[ansible-pulp3](https://github.com/pulp/ansible-pulp3) git repository must
The Pulp 3 Ansible installer consists of a collection of roles. Each role installs and configures a
component of Pulp. The roles are not currently available on Ansible Galaxy; to run the Pulp 3
Ansible installer, the [ansible-pulp3](https://github.com/pulp/ansible-pulp3) git repository must
be cloned.

Requirements
------------
System Requirements
-------------------

The [control node](https://docs.ansible.com/ansible/2.5/network/getting_started/basic_concepts.html#control-node)
must have Python 3 and Ansible installed.
Expand All @@ -21,27 +17,27 @@ must be one of these currently supported operating systems:
* Fedora 28
* CentOS 7

Knowledge of [Ansible](https://www.ansible.com/) is not necessary for the
[Vagrant](https://www.vagrantup.com/) installed, but will be very helpful for
installations that go beyond the default configuration.
Variables
---------

Required Variables
------------------
Each role documents all the variables that it uses in a separate README, and some variables are
shared between multiple roles.

Each role documents its own variables. Most have sane defaults, but a few are required.
**Required Variables:**
Most variables have sane defaults but a few are required. See ``example-use/group_vars/all`` for
the minimal set of required variables.


User Installation
Ansible Boilerplate
-----------------

These roles can be used against any managed node and are highly configurable.
Knowledge of [ansible basics](https://docs.ansible.com/ansible/2.5/user_guide/intro_getting_started.html)
will be helpful, but even if you are new to Ansible, this section will get you
started, or you can try the Vagrant installations to bypass the Ansible boilerplate.
These roles can be used against any managed node and are highly configurable. Knowledge of
[ansible basics](https://docs.ansible.com/ansible/2.5/user_guide/intro_getting_started.html) will
be helpful, but even if you are new to Ansible, this section will get you started, or you can try
the Vagrant installations to bypass the Ansible boilerplate.

First, you will need to configure ssh between your control node and your
managed node. When you can ssh into the managed node without a password, you
are ready to move to the next step.
First, you will need to configure ssh between your control node and your managed node. When you can
ssh into the managed node without a password, you are ready to move to the next step.

Next, add the managed node's hostname or ip address to `/etc/ansible/hosts`.

Expand All @@ -51,91 +47,48 @@ It may be helpful to ensure that Ansible can communicate with the managed node.
ansible all -m ping -u <managed_node_username>
```

You should now be able to run the example playbook. The playbook uses `become`
(root), so when prompted, you will need to provide the password for the managed
node user.
Using the example playbook
--------------------------

The playbook has external requirements which should be installed from ansible-galaxy.

```
ansible-galaxy install -r requirements.yml
ansible-playbook user-sandbox.yml -u <managed_node_username> --ask-become-pass
```

To configure a custom install, you will need to set configuration variables. In
the simplest case, they can be set in the playbook, which is done in our example
playbook, `user-sandbox.yml`. See the ansible docs for more flexible
alternatives.

All configuration options are documented in the README of the roles that use them.


Sandbox Quickstart
------------------

This section provides a fast and simple way to create a Pulp sandbox on a
Vagrant virtual machine that includes the
[pulp_file](https://github.com/pulp/pulp_file) plugin.

First, install some prerequisite packages:

`$ sudo dnf install vagrant ansible vagrant-libvirt vagrant-hostmanager`

After cloning this repository locally, you will need to create a Vagrantfile in
the root of the ansible-pulp3 directory.

`$ cp Vagrantfile.user.example Vagrantfile`
You should now be able to run the example playbook.

Thats it! Run Vagrant and you will have a Pulp sandbox.
Some of the roles used in the playbook use root privalages on the managed node, so when prompted,
you will need to provide the password for the managed node user.

`$ vagrant up`

You can ssh into the guest VM with `vagrant ssh` or you can access the web API
from your host machine. The hostname of the VM is `sandbox.pulp3` and the server
listens on port 80. If you have [httpie](https://httpie.org/) installed, an API
call to the sandbox would look like this:

`$ http --auth admin:password http://sandbox.pulp3/pulp/api/v3/status/`

For more on what you can do with your sandbox, we recommend using the
[pulp_file documentation](https://github.com/pulp/pulp_file/blob/master/README.rst)
next.

To install other plugins, simply add them to the vars in `user-sandbox.yml`. You
can rerun the playbook with `vagrant provision`.
```
ansible-playbook example-use/playbook.yml -u <managed_node_username> --ask-become-pass
```

Source Installation:
--------------------
To configure a custom install, you will need to set configuration variables. In the simplest case,
they can be set in the playbook. See the ansible docs for more flexible idiomatic alternatives.

This section will provide a Vagrant machine with editable source installs of
Pulp and the file plugin.

First, you will need to install system requirements. The provided Vagrantfile
Source installs require an additional package, `vagrant-sshfs`, to share files
with your guest virtual machine.
Testing
-------

`$ sudo dnf install vagrant ansible vagrant-sshfs vagrant-libvirt vagrant-hostmanager`
The tests can be run as they are on travis with **tox**, or they can run with various options using
**molecule** directly.

You will need to clone the necessary repositories. The provided
`Vagrantfile.source.example` requires that all git repositories are cloned into
a single parent directory.
**Requirements:**
Install Docker, and add yourself to the group that is authorized to
administer containers, and log out and back in to make the permissions change
take effect. The authorized group is typically the "docker" group:

```bash
gpasswd --add "$(whoami)" docker
```
$ git clone https://github.com/pulp/ansible-pulp3.git
$ git clone https://github.com/pulp/pulp.git
$ git clone https://github.com/pulp/pulpcore-plugin.git
$ git clone https://github.com/pulp/pulp_file.git
```

Create your Vagrantfile and use it.

```
$ cp Vagrantfile.source.example Vagrantfile
$ vagrant up
```
**NOTE:** Docker containers can differ from bare-metal or VM OS installs.
They can have different packages installed, they can run different kernels,
and so on.

Development
-----------

To run the test harness:
**Using Tox:**

1. Install [tox](https://tox.readthedocs.io/en/latest/). This can be done
through the system package manager or into a virtualenv:
Expand All @@ -147,24 +100,39 @@ To run the test harness:
```
2. Install at least one of the Python interpreters listed in tox.ini. These are
currently Python 2.7 and 3.6.
3. Install Docker, and add yourself to the group that is authorized to
administer containers, and log out and back in to make the permissions change
take effect. The authorized group is typically the "docker" group:

```bash
gpasswd --add "$(whoami)" docker
```

**WARNING:** Anyone added to the docker group is root equivalent. More
information [here](https://github.com/docker/docker/issues/9976) and
[here](https://docs.docker.com/engine/security/security/).

**NOTE:** Docker containers can differ from bare-metal or VM OS installs.
They can have different packages installed, they can run different kernels,
and so on.
4. Run `tox`. If you only have a subset of the supported Python interpreters
available, specify which environments to exercise:

```bash
tox -e py36
```

**Using Molecule:**

1. Install [molecule](https://molecule.readthedocs.io/en/latest/). It is recommended that you do so
with `pip` in a virtualenv.
2. Run molecule commands.

Test all scenarios on all hosts.
```bash
molecule test --all
```

Test a specific scenario.
```bash
molecule test --scenario-name source
```

Use debug for increased verbosity.
```bash
molecule --debug test --all
```

Create and provision, but don't run tests or destroy.
```bash
molecule converge --all
```
45 changes: 0 additions & 45 deletions Vagrantfile.sandbox.example

This file was deleted.

74 changes: 0 additions & 74 deletions Vagrantfile.source.example

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
pulp_secret_key: secret
---
pulp_default_admin_password: password

pulp_secret_key: secret
pulp_source_dir: '/var/lib/pulp/devel/pulp'
pulp_plugin_source_dir: "/var/lib/pulp/devel/pulpcore-plugin"
pulp_install_plugins:
pulp-file:
app_label: "file"
source_dir: "/var/lib/pulp/devel/pulp_file"

developer_user_home: /var/lib/pulp
developer_user: pulp
9 changes: 9 additions & 0 deletions example-source/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- hosts: all
roles:
- pulp3-postgresql
- pulp3-workers
- pulp3-resource-manager
- pulp3-webserver
- pulp3-content
- pulp3-devel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
pulp_secret_key: secret
pulp_default_admin_password: password
pulp_install_plugins:
Expand Down
8 changes: 8 additions & 0 deletions example-use/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- hosts: all
roles:
- pulp3-postgresql
- pulp3-workers
- pulp3-resource-manager
- pulp3-webserver
- pulp3-content
Loading

0 comments on commit 09c2fd2

Please sign in to comment.