Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding bootstrap script to local customize devel strategy #1061

Merged
merged 1 commit into from Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions docs/development.md
Expand Up @@ -159,9 +159,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 `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:
As an example, you can keep dotfiles such as `.bashrc` in the root of your git repository and install packages [with a `bootstrap` script](#running-a-boostrap-script) using this structure:
```
mygitrepo
- .bashrc
Expand All @@ -178,11 +176,18 @@ You can have files automatically copied over to the target user's home 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.

As an example, you can symlink files that are on your hypervisor to this directory and install packages [with a bootstrap script](#running-a-boostrap-script)

*Both of the local file and git repo custom file strategies are completely optional and are not required to spin up a development environment*

#### Running a boostrap script

For both the git and custom local file strategies, you can run commands from a boostrap script found in root level of the git repo or in `user_devel_env_files`

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 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 `./`).

#### Managing SSH keys

Github [provides documentation](https://developer.github.com/v3/guides/using-ssh-agent-forwarding/) on how to manage ssh keys using ssh agent forwarding, this can be useful when deploying forklift boxes.
Expand Down
13 changes: 13 additions & 0 deletions roles/customize_home/tasks/boostrap_script.yml
@@ -0,0 +1,13 @@
- name: Make boostrap file executable
file:
dest: "{{ ansible_env.HOME }}/{{ customize_home_bootstrap_script }}"
state: touch
follow: false
mode: a+x
when: bootstrap_script_path.stat.exists

# The script is already on the machine, so using 'command' instead of 'script'. 'script' copies the script from the Ansible controller
- name: Run custom bootstrap script
command: "{{ ansible_env.HOME }}/{{ customize_home_bootstrap_script }}"
when: bootstrap_script_path.stat.exists

9 changes: 0 additions & 9 deletions roles/customize_home/tasks/clone_specified_repo.yml
Expand Up @@ -28,12 +28,3 @@
path: "{{ ansible_env.HOME }}/tmp_custom_home/"
state: absent

- name: Check custom bootstrap script exists
stat:
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 }}/{{ customize_home_bootstrap_script }}"
when: bootstrap_script_path.stat.exists
9 changes: 9 additions & 0 deletions roles/customize_home/tasks/main.yml
Expand Up @@ -17,3 +17,12 @@

- include_tasks: clone_specified_repo.yml
when: customize_home_git_repo is defined

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

- include_tasks: boostrap_script.yml
when: bootstrap_script_path.stat.exists