Skip to content

Commit

Permalink
Updating docs and variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
John Mitsch authored and ehelms committed Nov 15, 2019
1 parent 6edba45 commit 18a0351
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ user_playbooks
playbooks/galaxy_roles
requirements.yml
inventories/local_*
user_devel_env_files/*
user_devel_env_files/

# Vagrant
.vagrant
Expand Down
13 changes: 8 additions & 5 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,18 @@ in your boxes.yaml entry to configure this on box creation.

#### Custom local files

You can have files automatically copied over to the working user's home directory (e.g. `~/vagrant`) when spinning up a `centos7-katello-devel` or `centos7-katello-devel-stable` box. To do so, add any files you want to be copied over to your development box to `user_devel_env_files/` found in forklift's root directory
You can have files automatically copied over to the target user's home directory when spinning up a `centos7-katello-devel` or `centos7-katello-devel-stable` box. Here are the steps to specify custom files to be copied over:

The directory `user_devel_env_files/` is ignored by git so the files won't be checked into version control. The files added to `user_devel_env_files/` will be copied over to `~/vagrant` on the development VM when it is created or provisioned.
1. Create the directoy `user_devel_env_files/` in Forklift's root directory.
2. Add any files you want to be copied over to your development box to `user_devel_env_files/`

As an example, you can keep dotfiles such as `.bashrc` in this directory.
The directory `user_devel_env_files/` is ignored by git so the files won't be checked into version control. The files added to `user_devel_env_files/` will be copied over to the target user's home directory on the development VM when it is created or provisioned.

As an example, you can keep sensitive files you don't want in version control here.

#### Custom files from git repo

A git repo's contents can be copied to the working user's home directory (e.g. `~/vagrant`) when spinning up a `centos7-katello-devel` or `centos7-katello-devel-stable` box. This can be done by specifying the `customize_home_git_repo` ansible variable. For example:
A git repo's contents can be copied to the target user's home directory when spinning up a `centos7-katello-devel` or `centos7-katello-devel-stable` box. This can be done by specifying the `customize_home_git_repo` ansible variable. For example:

```
centos7-katello-devel-stable:
Expand All @@ -167,7 +170,7 @@ centos7-katello-devel-stable:

The contents of the specified repo will be copied to the home directory excluding the `.git` folder and `.gitignore` file.

A file named `bootsrap` will be looked for in the home directory and executed if found. This can be used to run any commands you would like to during provisioning. Be sure to make the file executable and use the proper language [shebang](https://en.wikipedia.org/w/index.php?title=Shebang_(Unix)) at the top. A different script location can specified by using the `custom_bootstrap_script` variable. The `custom_bootstrap_script` variable needs to be specified in the format `path/to/my/script.sh` (don't prepend with `./`).
A file named `bootstrap` will be looked for in the home directory and executed if found. This can be used to run any commands you would like to during provisioning. Be sure to make the file executable and use the proper language [shebang](https://en.wikipedia.org/w/index.php?title=Shebang_(Unix)) at the top. A different script location can specified by using the `customize_home_bootstrap_script` variable. The `customize_home_bootstrap_script` variable needs to be specified in the format `path/to/my/script.sh` (don't prepend with `./`).

As an example, you can keep dotfiles such as `.bashrc` in the root of your git repository and install packages with a `bootstrap` script using this structure:
```
Expand Down
1 change: 0 additions & 1 deletion playbooks/setup_user_devel_environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# For roles to run after a stable Katello development image is provisioned
- hosts: all
roles:
- customize_home
2 changes: 1 addition & 1 deletion roles/customize_home/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
custom_bootstrap_script: 'bootstrap'
customize_home_bootstrap_script: 'bootstrap'
4 changes: 2 additions & 2 deletions roles/customize_home/tasks/clone_specified_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

- name: Check custom bootstrap script exists
stat:
path: "{{ ansible_env.HOME }}/{{ custom_bootstrap_script }}"
path: "{{ ansible_env.HOME }}/{{ customize_home_bootstrap_script }}"
register: bootstrap_script_path

# The script is already on the machine, so using 'command' instead of 'script', which copies the script from the Ansible controller
- name: Run custom bootstrap script
command: "{{ ansible_env.HOME }}/{{ custom_bootstrap_script }}"
command: "{{ ansible_env.HOME }}/{{ customize_home_bootstrap_script }}"
when: bootstrap_script_path.stat.exists
2 changes: 1 addition & 1 deletion roles/customize_home/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- name: Check for specified files to copy to home directory
local_action:
module: stat
path: "{{ role_path }}/files"
path: "{{ playbook_dir | dirname }}/user_devel_env_files/"
register: custom_home

- name: Copy files to home directory
Expand Down
Empty file removed user_devel_env_files/.gitkeep
Empty file.

0 comments on commit 18a0351

Please sign in to comment.