8000 GitHub - joetanx/cybr-aap: Integrate Ansible Automation Platform with CCP and Conjur
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

joetanx/cybr-aap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Integrate Ansible Automation Platform with CCP and Conjur

Introduction

  • The Ansible Automation Platorm can integrate with both CCP and Conjur products under the CyberArk secrets manager solution
  • This guide demonstrates the integration between AAP and CyberArk.

Software Versions

  • RHEL 9.1
  • Ansible Automation Platorm 2.3
  • Ansible Automation Controller 4.3
  • PAM/CCP 12.6
  • Conjur Enterprise 12.9.0

Servers

Hostname Role
cybr.ark.vx CCP server
conjur.vx Conjur master
aap.vx Ansible Automation Controller
foxtrot.vx Ansible managed node

1. Setup Ansible Automation Platorm

1.1. PostgreSQL server

  • AAP requires a PostgreSQL server, but this will be part of the Standalone automation controller with internal database installation processs from AAP version 2.3

1.2. Install AAP

tar xvf ansible-automation-platform-setup-bundle-2.3-1.4.tar.gz
cd ansible-automation-platform-setup-bundle-2.3-1.4

1.2.1. Edit the inventory file

  • Add the hostname of the controller under [automationcontroller]

[automationcontroller]
aap.vx ansible_connection=local
  • Set a password for the AAP admin login
  • Set the PostgreSQL server details

[all:vars]
admin_password='Cyberark1'

pg_host=''
pg_port=5432

pg_database='awx'
pg_username='awx'
pg_password='Cyberark1'
pg_sslmode='prefer'  # set to 'verify-full' for client-side enforced SSL
  • Set the container registry login credentials for the installer to push the execution environment container images

# Execution Environment Configuration

registry_url='registry.redhat.io'
registry_username='my_red_hat_username'
registry_password='my_red_hat_password'
  • Set the AAP SSL certificate (if you have any)

# SSL-related variables

# If set, this will install a custom CA certificate
8000
 to the system trust store.
custom_ca_cert=/tmp/certificate_authority.pem

# Certificate and key to install in nginx for the web UI and API
web_server_ssl_cert=/tmp/aap.pem
web_server_ssl_key=/tmp/aap.key

1.2.2. Run the setup script

./setup.sh

1.3. Prepare Ansible playbooks

  • The default directory for manual SCM is in /var/lib/awx/projects
  • Prepare the directory and download the demo playbooks
    • helloworld.yaml - this is a sample from Ansible
    • webserver.yaml - this installs apache web server in the managed node and deploy the index.html from index.html.j2 template
  • ☝️ Note: the sudo -i -u awx part of the commands is crucial, this runs the commands as awx user, so that we won't encounter permission issues on the directory/playbooks
sudo -i -u awx mkdir /var/lib/awx/projects/cybrdemo
sudo -i -u awx curl -o /var/lib/awx/projects/cybrdemo/helloworld.yaml https://raw.githubusercontent.com/ansible/ansible-tower-samples/master/hello_world.yml
sudo -i -u awx curl -o /var/lib/awx/projects/cybrdemo/webserver.yaml https://raw.githubusercontent.com/joetanx/cybr-aap/main/webserver.yaml
sudo -i -u awx curl -o /var/lib/awx/projects/cybrdemo/index.html.j2 https://raw.githubusercontent.com/joetanx/cybr-aap/main/index.html.j2

1.4. First login to AAP

1.5. Configure inventory, host, and project in AAP

image

  • Configure the managed node in this inventory

image

  • Configure a project: CyberArk Demo Project
    • Organization: Default
    • Execution Environment: Default execution environment
    • Source Control Type: Manual
    • Playbook Directory: cybrdemo (this is the directory prepared in 1.3., if you encounter folder-not-found errors, make sure that the preparation commands were run in awx user)

image

2. Prepare Ansible user on managed node

  • Create user and set password to Cyberark1
useradd ansible
echo -e "Cyberark1\nCyberark1" | (passwd ansible)
echo 'ansible ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/ansible
  • su to the ansible user
  • Generate ssh key pair and set to authorized_keys
su - ansible
mkdir ~/.ssh
ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa -q -N ""
cat /home/ansible/.ssh/id_rsa.pub > /home/ansible/.ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys

3. Integration with CCP

This section assumes that the PAM/CCP environment is already available.

3.1. Onboard SSH key for ansible user in PAM

  • Retrieve the private key for the user created in 2. and onboard them to PAM
  • Take note the safe where the SSH key is onboarded to, the Ansible application identity will be added as a member of this safe

image

3.2. Configure Application Identity in PAM

  • Create an application identity for the AAP
  • Optional: add the certificate serial number if you are using certificate authentication

image

  • Restrict where the application identity can be used from by adding the IP address of the AAP server; requests from any other sources will be rejected

image

  • Add the application identity as a member of the safe where the SSH key of the managed node is onboarded to
  • Permissions required:
    • List accounts
    • Retrieve accounts

image

3.3. Configure CCP as an external secrets management system

  • The following parameters are required for AAP to integrate with CCP
    • CyberArk AIM URL: the URL of the CCP server (or the load balancer, if CCP is behind a load balancer)
    • Application ID: the application identity configured in 3.2.
    • Client Key/Certificate: the PKI certificate used to authenticate the application identity
      • The serial number of the certificate needs to be added under Authentication in 3.2.
      • The CA chain of the certificate needs to be trusted by the CCP server

image

  • Test query to the onboarded account using query string Object=Operating System-vxUnixSSH-foxtrot.vx-ansible

image

3.4. Configure the machine credential for the managed node to lookup from CCP

  • Create new machine credential for the managed node

image

  • Select the Lookup to CCP as the external secret management system

image

  • Test query to the onboarded account using query string Object=Operating System-vxUnixSSHKeys-foxtrot.vx-ansible

image

  • Alternatively, queries to CCP can be also based on attributes, e.g. Safe=LinuxSSHKeys;Username=ansible;Address=foxtrot.vx
  • Ref: Query parameters

image

3.5. Setup and launch a Hello World job template

  • Create a job template that runs the helloworld.yaml playbook
  • This playbook performs the Ansible ping connection test task
  • Select Foxtrot from CCP credential created in 3.4.

image

  • Verify job template configuration and select launch

image

  • Verify job run success

image

3.6. Setup and launch a Web Server job template

  • Now that the hello world job is successful, let's do a more complex playbook to setup the managed node as a web server
  • The playbook runs the following tasks
    • Install apache using yum
    • Allow http service on firewalld
    • Enable the httpd service to start on machine boot
    • Deploy the template index.html.j2 as the index page
    • Restart the httpd services
  • Select Foxtrot from CCP credential created in 3.4.

image

  • Verify job template configuration and select launch

image

  • Verify job run success

image

  • Browse to the managed node to verify that web server deployment is successful

image

4. Integration with Conjur

This section assumes that the Conjur environment is already available.

Alternatively, setup Conjur master according to this guide: https://github.com/joetanx/setup/blob/main/conjur.md

4.1. Setup Conjur policy

  • Load the Conjur policy ansible-vars.yaml
    • Creates the policy ssh_keys
      • Creates variables username and sshprvkey to contain credentials for the Ansible managed node
      • Creates consumers group to authorize members of this group to access the variables
    • Creates the policy ansible with a same-name layer and a host demo
      • The AAP server will use the Conjur identity host/ansible/demo to retrieve credentials
      • Adds ansible layer to consumers group for ssh_keys policy
curl -O https://raw.githubusercontent.com/joetanx/conjur-ansible/main/ansible-vars.yaml
conjur policy load -b root -f ansible-vars.yaml
  • Note ☝️ : the API key of the Conjur identity host/ansible/demo will be shown on console after loading the policy, this key is required to configure Conjur as external secrets management system in 4.3.

  • Clean-up

rm -f ansible-vars.yaml

4.2. Store SSH keys for ansible user in Conjur

📌 Perform this section on the Ansible managed node

curl -L -O https://github.com/cyberark/cyberark-conjur-cli/releases/download/v7.1.0/conjur-cli-rhel-8.tar.gz
tar xvf conjur-cli-rhel-8.tar.gz
mv conjur /usr/local/bin/
  • Clean-up
rm -f conjur-cli-rhel-8.tar.gz
  • Initialize Conjur CLI and login to conjur
conjur init -u https://conjur.vx
conjur login -i admin -p CyberArk123!
  • Set the Conjur variable value for username and SSH private key
conjur variable set -i ssh_keys/username -v ansible
conjur variable set -i ssh_keys/sshprvkey -v "$(cat /home/ansible/.ssh/id_rsa && echo -e "\r")"

4.3. Configure Conjur as an external secrets management system

  • The following parameters are required for AAP to integrate with Conjur
    • Conjur URL: the URL of the Conjur master server (or the load balancer, if Conjur is clustered behind a load balancer)
    • Account: the account name of the Conjur deployment
    • Username: the host identity configured in 4.1.
    • API Key: the API key for the host identity, this is shown in console when loading the Conjur policy
    • Public Key Certificate: the certificate of the Conjur master/cluster or the issuer certificate used by AAP to verify legitimacy of Conjur

image

  • Test query to the ssh_keys/sshprvkey variable

image

4.4. Configure the machine credential for the managed node to lookup from Conjur

  • Create new machine credential for the managed node

image

  • Select the Lookup to Conjur as the external secret management system

image

  • Test query to the ssh_keys/sshprvkey variable

image

  • Note ☝️ : Notice that instead of entering the username, you can also configure the credential lookup to username variable (e.g. ssh_keys/username)

4.5. Setup and launch a Hello World job template

  • Create a job template that runs the helloworld.yaml playbook
  • This playbook performs the Ansible ping connection test task
  • Select Foxtrot from Conjur credential created in 4.4.

image

  • Verify job template configuration and select launch

image

  • Verify job run success

image

4.6. Setup and launch a Web Server job template

  • Now that the hello world job is successful, let's do a more complex playbook to setup the managed node as a web server
  • The playbook runs the following tasks
    • Install apache using yum
    • Allow http service on firewalld
    • Enable the httpd service to start on machine boot
    • Deploy the template index.html.j2 as the index page
    • Restart the httpd services
  • Select Foxtrot from Conjur credential created in 4.4.

image

  • Verify job template configuration and select launch

image

  • Verify job run success

image

  • Browse to the managed node to verify that web server deployment is successful

image

About

Integrate Ansible Automation Platform with CCP and Conjur

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0