-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Azimuth user outside of image build (#251)
* Setup Azimuth user creation in linux-data-volumes * Hardcode Azimuth user * Disable SSH for now * Move Guacamole user tasks to ansible-init * Revert "Disable SSH for now" This reverts commit 626a97d. * Parse openstack_userdata correctly * Fix ssh_key * Fix SSH keys again * Setup bind mount * Create linux-user role * Remove permissions config from data-volumes role * Fix repo2docker mountpoint * Fix user includes * Fix undefined SSH keys * Setup MOTD for Azimuth user * Remove managed text marker * Change init vars * Fix Zenith mounts * Remove azimuth_username variable * Use UID/GID from appliance * Update MOTD * Add Zenith SSH mountpoint to r-studio role * Update metadata variables * Update MOTD * Create the Azimuth user group
- Loading branch information
1 parent
63a78bd
commit 8987479
Showing
15 changed files
with
202 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
|
||
- hosts: localhost | ||
gather_facts: true | ||
vars: | ||
openstack_metadata: "{{ (lookup('url', 'http://169.254.169.254/openstack/latest/meta_data.json') | from_json).get('meta', {}) }}" | ||
openstack_userdata: "{{ (lookup('url', 'http://169.254.169.254/openstack/latest/user_data', split_lines=false) | from_yaml) }}" | ||
vars_files: | ||
- /etc/ansible-init/vars/user.yml | ||
tasks: | ||
- name: Get Azimuth user metadata | ||
ansible.builtin.set_fact: | ||
azimuth_uid: "{{ openstack_metadata['azimuth_uid'] | default('1005') }}" | ||
azimuth_gid: "{{ openstack_metadata['azimuth_gid'] | default('1005') }}" | ||
azimuth_is_sudo: "{{ openstack_metadata['azimuth_is_sudo'] | default('yes') }}" | ||
azimuth_ssh_keys: "{{ openstack_userdata.azimuth_users[0].ssh_authorized_keys | default([]) }}" | ||
|
||
- name: Setup Azimuth home directory | ||
ansible.builtin.file: | ||
path: "{{ user_mountpoint }}/azimuth-home" | ||
state: directory | ||
become: true | ||
|
||
- name: Setup bind mount for Azimuth home directory | ||
ansible.posix.mount: | ||
src: "{{ user_mountpoint }}/azimuth-home" | ||
path: "/home/azimuth" | ||
opts: bind | ||
fstype: none | ||
state: mounted | ||
become: true | ||
|
||
- name: Ensure the Azimuth group is created | ||
ansible.builtin.group: | ||
name: "azimuth" | ||
gid: "{{ azimuth_gid }}" | ||
become: true | ||
|
||
- name: Ensure the Azimuth user is created | ||
ansible.builtin.user: | ||
name: "azimuth" | ||
group: "azimuth" | ||
uid: "{{ azimuth_uid }}" | ||
shell: "/bin/bash" | ||
create_home: false | ||
become: true | ||
|
||
- name: Ensure Azimuth home directory has the correct permissions | ||
ansible.builtin.file: | ||
path: "{{ user_mountpoint }}" | ||
state: directory | ||
owner: "azimuth" | ||
group: "azimuth" | ||
mode: '750' | ||
recurse: true | ||
become: true | ||
|
||
- name: Setup public keys for the Azimuth user | ||
ansible.posix.authorized_key: | ||
user: "azimuth" | ||
state: present | ||
key: "{{ item }}" | ||
with_items: "{{ azimuth_ssh_keys }}" | ||
|
||
- name: Add the Azimuth user to sudoers | ||
ansible.builtin.user: | ||
name: "azimuth" | ||
groups: sudo | ||
when: azimuth_is_sudo == "yes" | ||
|
||
- name: Make sudo without password for users | ||
ansible.builtin.copy: | ||
dest: /etc/sudoers.d/80-ansible-sudo-user | ||
content: "azimuth ALL=(ALL) NOPASSWD:ALL" | ||
mode: 0440 | ||
when: azimuth_is_sudo == "yes" | ||
|
||
- name: Setup MOTD for user | ||
ansible.builtin.blockinfile: | ||
path: /etc/motd | ||
create: true | ||
marker: "" | ||
block: | | ||
Note that this user storage (/home/azimuth) is ephemeral, but is persistent through | ||
platform patches. All system level changes outside of the home directory will be lost | ||
on a platform patch. | ||
When configured by the Azimuth operator and supported by the platform, an additional | ||
filesystem is mounted at /project. This filesystem persists after the platform is deleted | ||
and is shared with other platforms in the tenancy. | ||
become: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
|
||
- name: Ensure ansible-init directories exist | ||
file: | ||
path: "/etc/ansible-init/{{ item }}" | ||
state: directory | ||
loop: | ||
- includes | ||
- playbooks | ||
- vars | ||
|
||
- name: Install ansible-init vars for users | ||
copy: | ||
content: "{{ user_init_vars | to_nice_yaml }}" | ||
dest: /etc/ansible-init/vars/user.yml | ||
vars: | ||
user_init_vars: | ||
user_mountpoint: /data | ||
|
||
- name: Install ansible-init playbook | ||
copy: | ||
src: user-create-playbook.yml | ||
# Leave some numbers for playbooks to execute before | ||
dest: /etc/ansible-init/playbooks/15-user-create.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters