diff --git a/Ansible/README.md b/Ansible/README.md index f08e7dd..591c237 100644 --- a/Ansible/README.md +++ b/Ansible/README.md @@ -10,9 +10,23 @@ This Ansible directory consists of the following directories that support the JF ## Getting Started 1. Install this collection from Ansible Galaxy. This collection is also available in RedHat Automation Hub. + ``` ansible-galaxy collection install jfrog.installers ``` + + Ensure you reference the collection in your playbook when using these roles. + + ``` + --- + - hosts: xray + collections: + - jfrog.installers + roles: + - xray + + ``` + 2. Ansible uses SSH to connect to hosts. Ensure that your SSH private key is on your client and the public keys are installed on your Ansible hosts. 3. Create your inventory file. Use one of the examples from the [examples directory](examples) to construct an inventory file (hosts.yml) with the host addresses and variables. @@ -21,7 +35,7 @@ This Ansible directory consists of the following directories that support the JF 5. Then execute with the following command to provision the JFrog software with Ansible. Variables can also be passed in at the command-line. - ``` +``` ansible-playbook -i hosts.yml playbook.yml --extra-vars "master_key=$(openssl rand -hex 16) join_key=$(openssl rand -hex 16)" ``` diff --git a/Ansible/ansible_collections/jfrog/installers/README.md b/Ansible/ansible_collections/jfrog/installers/README.md index e0449a9..bb6b243 100644 --- a/Ansible/ansible_collections/jfrog/installers/README.md +++ b/Ansible/ansible_collections/jfrog/installers/README.md @@ -1,70 +1,42 @@ # JFrog Ansible Installers Collection -This collection provides roles for installing Artifactory and Xray. Additionally, it provides optional SSL and Postgresql roles if these are needed for your deployment. -## Roles Provided -### artifactory -The artifactory role installs the Artifactory Pro software onto the host. Per the Vars below, it will configure a node as primary or secondary. This role uses secondary roles artifactory_nginx to install nginx. - -### artifactory_nginx_ssl -The artifactory_nginx_ssl role installs and configures nginx for SSL. - -### postgres -The postgres role will install Postgresql software and configure a database and user to support an Artifactory or Xray server. - -### xray -The xray role will install Xray software onto the host. An Artifactory server and Postgress database is required. - -## Vars Required -The following Vars must be configured. - -### databsase vars -* _db_users_: This is a list of database users to create. eg. db_users: - { db_user: "artifactory", db_password: "Art1fAct0ry" } -* _dbs_: This is the database to create. eg. dbs: - { db_name: "artifactory", db_owner: "artifactory" } - -### artifactory vars -* _artifactory_version_: The version of Artifactory to install. eg. "7.4.1" -* _master_key_: This is the Artifactory [Master Key](https://www.jfrog.com/confluence/display/JFROG/Managing+Keys). See below to [autogenerate this key](#autogenerating-master-and-join-keys). -* _join_key_: This is the Artifactory [Join Key](https://www.jfrog.com/confluence/display/JFROG/Managing+Keys). See below to [autogenerate this key](#autogenerating-master-and-join-keys). -* _db_download_url_: This is the download URL for the JDBC driver for your database. eg. "https://jdbc.postgresql.org/download/postgresql-42.2.12.jar" -* _db_type_: This is the database type. eg. "postgresql" -* _db_driver_: This is the JDBC driver class. eg. "org.postgresql.Driver" -* _db_url_: This is the JDBC database url. eg. "jdbc:postgresql://10.0.0.120:5432/artifactory" -* _db_user_: The database user to configure. eg. "artifactory" -* _db_password_: The database password to configure. "Art1fact0ry" -* _server_name_: This is the server name. eg. "artifactory.54.175.51.178.xip.io" -* _system_file_: Your own [system YAML](https://www.jfrog.com/confluence/display/JFROG/System+YAML+Configuration+File) file can be specified and used. **If specified, this file will be used rather than constructing a file from the parameters above.** -* _binary_store_file_: Your own [binary store file](https://www.jfrog.com/confluence/display/JFROG/Configuring+the+Filestore) can be used. If specified, the default cluster-file-system will not be used. - -### primary vars (vars used by the primary Artifactory server) -* _artifactory_is_primary_: For the primary node this must be set to **true**. -* _artifactory_license1 - 5_: These are the cluster licenses. -* _artifactory_license_file_: Your own license file can be used. **If specified, a license file constructed from the licenses above will not be used.** - -### secondary vars (vars used by the secondary Artifactory server) -* _artifactory_is_primary_: For the secondary node(s) this must be set to **false**. - -### ssl vars (Used with artifactory_nginx_ssl role) -* _certificate_: This is the SSL cert. -* _certificate_key_: This is the SSL private key. - -### xray vars -* _xray_version_: The version of Artifactory to install. eg. "3.3.0" -* _jfrog_url_: This is the URL to the Artifactory base URL. eg. "http://ec2-54-237-207-135.compute-1.amazonaws.com" -* _master_key_: This is the Artifactory [Master Key](https://www.jfrog.com/confluence/display/JFROG/Managing+Keys). See below to [autogenerate this key](#autogenerating-master-and-join-keys). -* _join_key_: This is the Artifactory [Join Key](https://www.jfrog.com/confluence/display/JFROG/Managing+Keys). See below to [autogenerate this key](#autogenerating-master-and-join-keys). -* _db_type_: This is the database type. eg. "postgresql" -* _db_driver_: This is the JDBC driver class. eg. "org.postgresql.Driver" -* _db_url_: This is the database url. eg. "postgres://10.0.0.59:5432/xraydb?sslmode=disable" -* _db_user_: The database user to configure. eg. "xray" -* _db_password_: The database password to configure. "xray" -* _system_file_: Your own [system YAML](https://www.jfrog.com/confluence/display/JFROG/System+YAML+Configuration+File) file can be specified and used. If specified, this file will be used rather than constructing a file from the parameters above. - -## Example Inventory and Playbooks -Example playbooks are located in the [examples](../examples) directory. This directory contains several example inventory and playbooks for different Artifactory, HA and Xray architectures. - -## Executing a Playbook -``` -ansible-playbook -i +This Ansible directory consists of the following directories that support the JFrog Ansible collection. + + * [ansible_collections directory](ansible_collections) - This directory contains the Ansible collection package that has the Ansible roles for Artifactory and Xray. See the collection [README](ansible_collections/README.md) for details on the available roles and variables. + * [examples directory](examples) - This directory contains example playbooks for various architectures from single Artifactory (RT) deployments to high-availability setups. + * [infra directory](infra) - This directory contains example infrastructure templates that can be used for testing and as example deployments. + * [test directory](test) - This directory contains Gradle tests that can be used to verify a deployment. It also has Ansible playbooks for creating infrastructure, provisioning software and testing with Gradle. + + ## Getting Started + + 1. Install this collection from Ansible Galaxy. This collection is also available in RedHat Automation Hub. + + ``` + ansible-galaxy collection install jfrog.installers + ``` + + Ensure you reference the collection in your playbook when using these roles. + + ``` + --- + - hosts: xray + collections: + - jfrog.installers + roles: + - xray + + ``` + + 2. Ansible uses SSH to connect to hosts. Ensure that your SSH private key is on your client and the public keys are installed on your Ansible hosts. + + 3. Create your inventory file. Use one of the examples from the [examples directory](examples) to construct an inventory file (hosts.yml) with the host addresses and variables. + + 4. Create your playbook. Use one of the examples from the [examples directory](examples) to construct a playbook using the JFrog Ansible roles. These roles will be applied to your inventory and provision software. + + 5. Then execute with the following command to provision the JFrog software with Ansible. Variables can also be passed in at the command-line. + + ``` +ansible-playbook -i hosts.yml playbook.yml --extra-vars "master_key=$(openssl rand -hex 16) join_key=$(openssl rand -hex 16)" ``` ## Autogenerating Master and Join Keys diff --git a/Ansible/ansible_collections/jfrog/installers/galaxy.yml b/Ansible/ansible_collections/jfrog/installers/galaxy.yml index 398304a..4c7bdc6 100644 --- a/Ansible/ansible_collections/jfrog/installers/galaxy.yml +++ b/Ansible/ansible_collections/jfrog/installers/galaxy.yml @@ -9,7 +9,7 @@ namespace: "jfrog" name: "installers" # The version of the collection. Must be compatible with semantic versioning -version: "1.0.5" +version: "1.0.6" # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: "README.md" @@ -52,9 +52,7 @@ dependencies: {} repository: "https://github.com/jfrog/JFrog-Cloud-Installers/" # The URL to any online docs -documentation: - - "https://github.com/jfrog/JFrog-Cloud-Installers/blob/master/Ansible/README.md" - - "https://www.jfrog.com/confluence/display/JFROG/" +documentation: "https://github.com/jfrog/JFrog-Cloud-Installers/blob/master/Ansible/README.md" # The URL to the homepage of the collection/project homepage: "https://github.com/jfrog/JFrog-Cloud-Installers/" diff --git a/Ansible/ansible_collections/jfrog/installers/jfrog-installers-1.0.5.tar.gz b/Ansible/ansible_collections/jfrog/installers/jfrog-installers-1.0.5.tar.gz deleted file mode 100644 index 80395da..0000000 Binary files a/Ansible/ansible_collections/jfrog/installers/jfrog-installers-1.0.5.tar.gz and /dev/null differ diff --git a/Ansible/ansible_collections/jfrog/installers/jfrog-installers-1.0.6.tar.gz b/Ansible/ansible_collections/jfrog/installers/jfrog-installers-1.0.6.tar.gz new file mode 100644 index 0000000..53a4413 Binary files /dev/null and b/Ansible/ansible_collections/jfrog/installers/jfrog-installers-1.0.6.tar.gz differ diff --git a/Ansible/examples/playbook-rt-ha.yml b/Ansible/examples/playbook-rt-ha.yml index 151d2df..57fc65c 100644 --- a/Ansible/examples/playbook-rt-ha.yml +++ b/Ansible/examples/playbook-rt-ha.yml @@ -1,9 +1,13 @@ --- - hosts: database + collections: + - jfrog.installers roles: - postgres - hosts: primary:secondary + collections: + - jfrog.installers roles: - artifactory - artifactory_nginx_ssl \ No newline at end of file diff --git a/Ansible/examples/playbook-rt-xray.yml b/Ansible/examples/playbook-rt-xray.yml index 9c0ff31..6081198 100644 --- a/Ansible/examples/playbook-rt-xray.yml +++ b/Ansible/examples/playbook-rt-xray.yml @@ -1,12 +1,18 @@ --- - hosts: database + collections: + - jfrog.installers roles: - postgres - hosts: artifactory + collections: + - jfrog.installers roles: - artifactory - hosts: xray + collections: + - jfrog.installers roles: - xray \ No newline at end of file diff --git a/Ansible/examples/playbook-rt.yml b/Ansible/examples/playbook-rt.yml index 48d7c1e..72ffbec 100644 --- a/Ansible/examples/playbook-rt.yml +++ b/Ansible/examples/playbook-rt.yml @@ -1,8 +1,12 @@ --- - hosts: database + collections: + - jfrog.installers roles: - postgres - hosts: primary + collections: + - jfrog.installers roles: - artifactory diff --git a/Ansible/examples/playbook-ssl.yml b/Ansible/examples/playbook-ssl.yml index 33d84c2..7370111 100644 --- a/Ansible/examples/playbook-ssl.yml +++ b/Ansible/examples/playbook-ssl.yml @@ -1,9 +1,13 @@ --- - hosts: database + collections: + - jfrog.installers roles: - postgres - hosts: primary + collections: + - jfrog.installers roles: - artifactory - artifactory_nginx_ssl diff --git a/Ansible/examples/playbook-xray.yml b/Ansible/examples/playbook-xray.yml index 1f19914..3f0e5a4 100644 --- a/Ansible/examples/playbook-xray.yml +++ b/Ansible/examples/playbook-xray.yml @@ -1,4 +1,6 @@ --- - hosts: xray + collections: + - jfrog.installers roles: - xray \ No newline at end of file diff --git a/Ansible/pipelines.yaml b/Ansible/pipelines.yaml index 45a5731..96a1271 100644 --- a/Ansible/pipelines.yaml +++ b/Ansible/pipelines.yaml @@ -34,6 +34,12 @@ pipelines: - sudo apt -y --allow-unauthenticated install ansible - sudo pip install packaging - sudo pip install boto3 botocore + - pwd + - ls + - ls workspace + - ls dependencyState + - ls dependencyState/resources + - ls dependencyState/resources/ansibleRepo - cd ../dependencyState/resources/ansibleRepo - echo 'Setting environment variables...' - export artifactory_version="$int_ansibleEnvVars_artifactory_version" @@ -84,6 +90,12 @@ pipelines: - sudo pip install packaging - sudo pip install msrestazure - sudo pip install ansible[azure] + - pwd + - ls + - ls workspace + - ls dependencyState + - ls dependencyState/resources + - ls dependencyState/resources/ansibleRepo - cd ../dependencyState/resources/ansibleRepo - echo 'Setting environment variables...' - export artifactory_version="$int_ansibleEnvVars_artifactory_version" diff --git a/Ansible/test/aws/playbook.yaml b/Ansible/test/aws/playbook.yaml index 26cc90d..a859072 100644 --- a/Ansible/test/aws/playbook.yaml +++ b/Ansible/test/aws/playbook.yaml @@ -37,7 +37,9 @@ db_url: "jdbc:postgresql://{{ AWSDeployment.stack_outputs.DBInstancePrivate }}:5432/artifactory" server_name: "{{ AWSDeployment.stack_outputs.ALBHostName }}" artifactory_is_primary: true - artifactory_license_file: "{{ lookup('env', 'artifactory_license_file') }}" + artifactory_license1: "{{ lookup('env', 'artifactory_license1') }}" + artifactory_license2: "{{ lookup('env', 'artifactory_license2') }}" + artifactory_license3: "{{ lookup('env', 'artifactory_license3') }}" groups: - artifactory