Skip to content

Commit

Permalink
Merge pull request #721 from cisagov/improvement/create_more_director…
Browse files Browse the repository at this point in the history
…ies_at_build_time

Create the `/etc/cyhy` directory at AMI build time
  • Loading branch information
mcdonnnj authored Nov 16, 2023
2 parents 958b6c2 + afbe339 commit 8ffd68b
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 33 deletions.
11 changes: 0 additions & 11 deletions ansible/roles/cyhy_commander/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@
mode: 0600
owner: cyhy

#
# Create the cyhy directory in etc for commander conf
#
- name: Create the /etc/cyhy directory
ansible.builtin.file:
group: cyhy
mode: 0755
owner: cyhy
path: /etc/cyhy
state: directory

#
# Copy the cyhy-commander conf file
#
Expand Down
7 changes: 2 additions & 5 deletions ansible/roles/cyhy_dashboard/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
---
- name: Create needed directories
- name: Create the /var/cyhy/web directory
ansible.builtin.file:
group: cyhy
mode: 0750
owner: cyhy
path: "{{ item }}"
path: /var/cyhy/web
state: directory
loop:
- /etc/cyhy
- /var/cyhy/web

- name: Create secret key file for webd
ansible.builtin.file:
Expand Down
6 changes: 0 additions & 6 deletions ansible/roles/cyhy_reporter/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
#
# Set up /etc/cyhy/cyhy.conf
#
- name: Create the /etc/cyhy directory
ansible.builtin.file:
mode: 0755
path: /etc/cyhy
state: directory

- name: Create /etc/cyhy/cyhy.conf
ansible.builtin.template:
dest: /etc/cyhy/cyhy.conf
Expand Down
8 changes: 0 additions & 8 deletions ansible/roles/nessus/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@
name: nessusd
state: started

- name: Create /etc/cyhy directory
ansible.builtin.file:
group: cyhy
mode: 0750
owner: cyhy
path: /etc/cyhy
state: directory

- name: Create the configuration file for Nessus API access
ansible.builtin.template:
dest: /etc/cyhy/nessus_api.yml
Expand Down
15 changes: 15 additions & 0 deletions packer/ansible/create_credentials_directory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- hosts: cyhy_commander,cyhy_dashboard,cyhy_reporter,nessus
name: Create the directory used for cyhy-commander, cyhy-core, and Nessus credentials
become: yes
become_method: ansible.builtin.sudo
tasks:
- name: Create the /etc/cyhy directory
ansible.builtin.file:
group: "{{ cyhy_user_username }}"
mode: 0750
owner: "{{ cyhy_user_username }}"
path: /etc/cyhy
state: directory
vars_files:
- vars/cyhy_user.yml
8 changes: 5 additions & 3 deletions packer/ansible/create_cyhy_user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
- name: Create the cyhy user
ansible.builtin.user:
home: /var/cyhy
name: cyhy
name: "{{ cyhy_user_username }}"
shell: /bin/bash
uid: 2048
uid: "{{ cyhy_user_uid }}"
register: user_info

- name: Modify permissions on the home directory
Expand All @@ -22,4 +22,6 @@
- name: Add the SSH public key as an authorized key
ansible.posix.authorized_key:
key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOreUDnms12MPI0gh7K+YGaESYgC2TY1zA+kSK/g+n5+ cyhy
user: cyhy
user: "{{ cyhy_user_username }}"
vars_files:
- vars/cyhy_user.yml
3 changes: 3 additions & 0 deletions packer/ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
- name: Import cyhy user creation playbook
ansible.builtin.import_playbook: create_cyhy_user.yml

- name: Import credentials directory creation playbook
ansible.builtin.import_playbook: create_credentials_directory.yml

- name: Import the nmap host playbook
ansible.builtin.import_playbook: nmap.yml

Expand Down
4 changes: 4 additions & 0 deletions packer/ansible/vars/cyhy_user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# CyHy user information
cyhy_user_uid: 2048
cyhy_user_username: cyhy

0 comments on commit 8ffd68b

Please sign in to comment.