Coder Social home page Coder Social logo

ansible-alfresco's Introduction

Example Ansible Alfresco Setup

This project is an example of one way to automate Alfresco installation and configuration management.

Setup

Here are the high-level steps you'll need to perform before running any of the playbooks with Ansible:

  1. Setup SSH Keys
  2. Clone this project to your local machine.
  3. Edit the inventory file. Add your Alfresco and SOLR hosts to the appropriate groups. It is okay if the Alfresco and SOLR machine are the same.
  4. Edit the group_vars for the groups you just populated in the inventory file to override the variables declared in group_var/all with values specific to the group.
  5. Setup Ansible Vault to encrypt passwords
  6. Collect dependencies such as the ACS distribution zip, ASS distribution zip, Tomcat, ActiveMQ, and database driver.

Let's look at some of these setup steps in further detail.

Setup SSH keys

The easiest way to authenticate with each of the machines in your inventory is to use SSH keys. For example, if the user you will run Alfresco and SOLR with is "alfresco" make sure you can ssh to each box in your inventory as the alfresco user without providing a password.

The steps to set this up are well-documented online, but it typically involves:

ssh-keygen -t rsa
ssh-copy-id [email protected]

And you may want to edit ~/.ssh/config on your local machine so that you don't have to specify the SSH key when using ssh or scp:

Host alfresco.someco.com
  IdentityFile ~/.ssh/someco_id_rsa

Edit the inventory file

The inventory file tells Ansible about your environments, including each host name and the role it plays in your stack.

In this project, the ansible.cfg file specifies that our default inventory file is named "inventory" and lives in the root of the project.

The inventory file is pre-populated with sample groups that assume you have three environments, dev, test, and prod. There is one group each for Alfresco and SOLR per environment for a total of six groups.

The "local" group is used for testing the playbook using local virtual machines managed by Vagrant and can be ignored. If you want to learn more about how that works, see the README.md file in the local directory.

Edit group variables

Ansible Templates have variables and the value of those variables can differ by group. The group_vars directory has one folder per group. Within that there is a vars file and a vault file (see next section on Vault).

There is a special group named "all". The vars file in the group_vars/all directory defines default values for all variables. If you introduce new variables, make sure you add them to group_vars/all/vars.

Each group can optionally override the value declared in all by specifying a new value for that variable in its own group_vars vars file.

For example, the default database name is declared as "alfresco" in all:

alf_db_name: alfresco

Suppose that in the dev environment we want to name the database something else. To do that, we'd edit group_vars/alfresco_dev/vars with:

alf_db_name: alfrescodev

In this example, all templates rendered for all servers in the alfresco_dev group will have "alfrescodev" set as the value for alf_db_name.

Here are some key variables you should review before running:

  • alf_home: The Alfresco home directory. Typically should be a soft link to a version specific directory.
  • alf_install_dir: A version specific directory where Alfresco is installed.
  • alf_archive: The file name of the ACS distribution zip.
  • tomcat_archive: The file name of the Apache Tomcat tar file.
  • search_archive: The file name of the Alfresco Search Services distribution zip.
  • alf_db_driver: The hibernate dialect.
  • alf_db_driver_file: The file name of the database driver.
  • activemq_archive: The file name of the Apache ActiveMQ tar file.
  • alf_java_home: The path to the Java home directory.

It's best to rely on group_vars as much as possible, but if you need to you can also have host-specific variables by creating a directory called "host_vars" and creating directories named for specific hosts below that.

Managing secrets using Ansible Vault

The Ansible Vault docs are worth reading, but here's how it works at a high-level:

  • Each group folder has a file called vars for that group's plain-text variables, and, optionally, a file called vault for that group's encrypted variables.

  • The ansible.cfg file points to the Ansible Vault password file location which is .vault-passwd. This password should be shared with your team, but don't check it in to source code control. NOTE: This file is not distributed as part of this project. You'll need to create your own. To do that, just create a file named ".vault-passwd" and put it in the root of your project (adjacent to this README.md file). The file should contain one line with the value of your vault password.

  • Variables that need to be encrypted will have a plain variable name and a vault variable name. For example, in group_vars/all/vars the following will use the value from the vault for the Alfresco DB password:

    alf_db_password: "{{ vault_alf_db_password }}"
    
  • From the root of the project, use ansible-vault edit group_vars/all/vault to edit a vault file (in this example, it is the all group, but each group can have its own vault file).

  • Ansible Vault will launch a configurable editor. On save, the value will be encrypted using the Ansible Vault password.

  • To set values for the vault variables that are used in this project, copy and paste the following into your vault file (use whatever values you want, these mimic what used to be set by the installer):

    vault_alf_db_password: admin
    vault_alf_initial_admin_password: "209c6174da490caeb422f3fa5a7ae634"
    vault_alf_jmx_monitor_password: monitor_password
    vault_alf_jmx_control_password: control_password
    vault_alf_keystore_password: kT9X6oe68t
    vault_alf_truststore_password: kT9X6oe68t
    
  • When setting up a new vault for the first time use ansible-vault encrypt group_vars/all/vault to encrypt the file. After that, just use ansible-vault edit group_vars/all/vault.

  • You should now have an encrypted vault file that uses your own vault password that is stored in .vault-passwd. When you do ansible-vault edit you should see the values for the database password, JMX passwords, and key/truststore passwords.

Remember that secrets are only encrypted on your local machine. Ansible decrypts the value in memory when the playbook runs, and then delivers the value to the target in plain text.

Gathering Dependencies

If you are using the playbook to install Alfresco Content Services and/or Alfresco Search Services you will need to gather a few dependencies. Here is a list of what you need and where they go:

File Description Example Source Put It Here
ACS Distribution alfresco-content-services-community-distribution-6.2.0-ga.zip alfresco.com (or support for Enterprise) files/third-party
Apache Tomcat apache-tomcat-8.5.34.tar.gz tomcat.apache.com files/third-party
ASS Distribution alfresco-search-services-1.4.0.zip alfresco.com files/third-party
Database driver postgresql-42.2.1.jar Database vendor files/third-party
Apache ActiveMQ apache-activemq-5.15.6-bin.tar.gz activemq.apache.com files/third-party

You can optionally deploy AMPs as part of installation or as a separate playbook. Put AMPs in files/third-party/amps or files/third-party/amps_share depending on what type of AMP it is.

Note that AOS and Share Services AMPs are shipped with the distribution ZIP so there is no need to put those in the amps/amps_share directory with custom or third-party AMPs.

Installing Alfresco and Search

Prepare the target machines

The installation playbook assumes you do not have root access to the target machines. It assumes certain tasks have already been performed. You'll need to perform these tasks before running the install playbook:

  • Create an alfresco user and group
  • Create an install directory owned by the alfresco user and group
  • Increase file handles
  • Install Java
  • Install a database (if it is going to be local)
  • Install LibreOffice
  • Install ImageMagick
  • Open appropriate ports in the firewall
  • Create init.d/systemctl scripts for Alfresco and ActiveMQ
  • Attach and mount any needed NFS mounts or other storage volumes

If you have root access to the server (either directly or via sudo), you can modify the playbook to perform all of these tasks for you.

Run the playbook to install Alfresco Content Services

Once all pre-requisites are in place, install Alfresco by running:

ansible-playbook installAlfresco.yml --extra-vars="hosts=alfresco_dev"

Where "alfresco_dev" is the desired group.

SSH to each Alfresco server and start up ActiveMQ and ACS:

cd /opt/alfresco
./activemq/bin/activemq start
./tomcat/bin/startup.sh

The startup commands might look a little different if you have init.d/systemctl scripts in place.

Run the playbook to install Alfresco Search Services

Now install Alfresco Search Services by running:

ansible-playbook installSearch.yml --extra-vars="hosts=solr_dev"

Next, SSH to each SOLR server and start it up so it can init the cores:

cd /opt/alfresco/alfresco-search-services
./solr/bin/solr start -a "-Dcreate.alfresco.defaults=alfresco,archive"

Let it populate the core configurations, then:

./solr/bin/solr stop

Back on your local machine, run a playbook to remove any indices that were created:

ansible-playbook removeSolrIndexMetadata.yml --extra-vars="hosts=solr_dev"

Then, run a playbook to copy the SOLR core config into place:

ansible-playbook copySolrCoreConfig.yml --extra-vars="hosts=solr_dev"

Finally, SSH to each SOLR server and start it up:

cd /opt/alfresco/alfresco-search-services
./solr/bin/solr start

Copying Configuration Files

The installation playbooks copy Alfresco and SOLR configuration files to the servers in the target group for you. Outside of an installation or upgrade you may need to deploy configuration updates. To do that, run one of the "copy" playbooks:

ansible-playbook copyAllAlfrescoConfig.yml --extra-vars="hosts=alfresco_dev"
ansible-playbook copySolrCoreConfig.yml --extra-vars="solr_dev"

You might consider creating additional playbooks for doing other types of maintenance such as deploying AMPs.

Dry-run

Use the --check flag to tell Ansible to do a dry-run, like this:

ansible-playbook copyAllAlfrescoConfig.yml --check --extra-vars="hosts=alfresco_dev"

The output will show you what would have been changed had you not used the flag.

Use the --diff flag along with --check to see the difference between the configuration in your current project and what is currently on the server, like this:

ansible-playbook copyAllAlfrescoConfig.yml --diff --check --extra-vars="hosts=alfresco_dev"

The output will show you a difference between what is currently on the target and what would have been deployed without the flags.

Security

Running the installation playbook as provided in this example setup will result in an Alfresco server with no SSL certificates configured, either for ACS or for SOLR. It also uses a "admin" as the admin user password. You will need to make changes appropriate for your environment to properly secure your install.

ansible-alfresco's People

Contributors

jpotts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ansible-alfresco's Issues

alfresco user shoud be able to login ? (.bash_profile)

Hi jpotts,
the task doCopyAlfrescoConfig.yml is copying the alfresco bash profile in the managed server.

Usually the alfresco user is supposed to be created as a system user, that is a not loging user like
sudo adduser --system --disabled-login --disabled-password --group "$ALF_USER"

Considering you are copying the interactive bash profile, with your installation do you intend the alfresco user to be able to log in ?
When do you need to log in as alfresco user ?

pdf renderer placed in different directory from global.properties

Hi jpotts
maybe there is a problem in tasks/doInstallPDFRenderer.yml

The pdf renderer is not found:

2021-02-08 12:56:28,871 ERROR [transform.pdfrenderer.AlfrescoPdfRendererContentTransformerWorker] [main] Legacy Alfresco PDF Renderer is not available for transformations. Execution result: os: Linux command: /opt/alfresco/common/alfresco-pdf-renderer/alfresco-pdf-renderer --version succeeded: false exit code: 1 out: err: Cannot run program "/opt/alfresco/common/alfresco-pdf-renderer/alfresco-pdf-renderer": error=20, Non è una directory

The template for alfresco.global properties is set to:

alfresco-pdf-renderer.root={{ alf_home }}/common/alfresco-pdf-renderer
alfresco-pdf-renderer.exe=${alfresco-pdf-renderer.root}/alfresco-pdf-renderer

But the insaller is using a different DEST directory for pdf-rederer (one level higher)

- name: Extract PDF Renderer
  unarchive:
    src: '{{ alf_home }}/dist/{{ alf_archive_root_dir }}/alfresco-pdf-renderer/alfresco-pdf-renderer-1.1-linux.tgz'
    dest: '{{ alf_home }}/common'
    copy: no	

PROPOSAL: One of the two files should be changed (the task or the properties) accordingly.

Confirm whether or not removing initial metadata dirs from cores is needed

PS
BTW... can you explain why AFTER having create a brand new index SOLR6 with the command

./solr/bin/solr start -a "-Dcreate.alfresco.defaults=alfresco,archive"

your are deliting them and coping a backup from your ansible template ?

I found documentation of the first command (Dcreate) but I do NOT find any documentation requiring to delete the indexes and restore a backup copy....
WHY are you proceeding this way ?
WHERE did you get the documentation for that ?

Originally posted by @Giuliano69 in #5 (comment)

Vault password file .vault-passwd missing ?

Hi jpotts,
in ansible.cfg, the following file is pointed
vault_password_file = .vault-passwd
but it is NOT PRESENT in the directory.
I get this error: Using ansible 2.9.6

$ ansible-playbook installAlfresco.yml --extra-vars="hosts=alfresco_test"
ERROR! The vault password file /home/giuliano/Scrivania/alfresco/ansible-alfresco-master/.vault-passwd was not found

Is the password file .vault-password missing ?
Which is the password ?

ALSO
I see in vars that exist some passowrd crypted in vault (alfrescodb, alfresco admin,....) But I cannot find how to decript them:
, When I try
$ ansible-vault edit group_vars/all/vault
I get (I tried the passords: admin, alfresco, ...) :

Vault password: 
ERROR! Decryption failed (no vault secrets were found that could decrypt) for /home/giuliano/Scrivania/alfresco/ansible-alfresco-master/group_vars/all/vault

PS
Googling around I found that there are some problems with .vault-passowrd.
But I should be using a version NOT affected by such bug.
ansible/ansible#32486

No Solr connection with new vault values

Hi Jpotts,
I tryed the same machine with the new config (vault file)
I can confirm that the MD4 hash of admin password is working; (we can access coorrectly Alfresco share as admin)

BUT solr6 stopped to connect to alfresco and any search query is NOW empty.
Of course, SSL is disabled, but it seems that something has changed considering the new results (no connection)
In solr.log I get

2021-02-08 18:40:40.046 ERROR (org.alfresco.solr.AlfrescoCoreAdminHandler@5f78de22_Worker-40) [   ] o.a.s.t.AbstractTracker Tracking failed for ModelTracker - alfresco java.net.UnknownHostException: alfdev1.metaversant.com
...
2021-02-08 18:40:40.021 ERROR (org.alfresco.solr.AlfrescoCoreAdminHandler@5f78de22_Worker-26) [   ] o.a.s.t.AbstractTracker Tracking failed for AclTracker - archive java.net.UnknownHostException: alfdev1.metaversant.com

And in tomcat log I get

2021-02-08 19:14:53,775  ERROR [extensions.webscripts.AbstractRuntime] [http-nio-8080-exec-9] Exception from executeScript: 01080024 Wrapped Exception (with status template): 01080181
Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js': 01080180 Failed to execute search: +PATH:"/app:company_home/st:sites/cm:montblanc/cm:documentLibrary//*" +@cm\:modified:[2021\-2\-1T00\:00\:00.000 TO 2021\-2\-8T23\:59\:59.999] +@cm\:modifier:"admin" +TYPE:"cm:content" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fm:post" +(TYPE:"content" OR TYPE:"app:filelink" OR TYPE:"folder")
org.springframework.extensions.webscripts.WebScriptException: 01080024 Wrapped Exception (with status template): 01080181 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js': 01080180 Failed to execute search: +PATH:"/app:company_home/st:sites/cm:montblanc/cm:documentLibrary//*" +@cm\:modified:[20
21\-2\-1T00\:00\:00.000 TO 2021\-2\-8T23\:59\:59.999] +@cm\:modifier:"admin" +TYPE:"cm:content" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fm:post" +(TYPE:"content" OR TYPE:"app:filelink" OR TYPE:"folder")
...
Caused by: org.alfresco.scripts.ScriptException: 01080181 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js': 01080180 Failed to execute search: +PATH:"/app:company_home/st:sites/cm:montblanc/cm:documentLibrary//*" +@cm\:modified:[2021\-2\-1T00\:00\:00.000 TO 2021\-2\-8T23\:59\:59.999] +@cm\:modi
fier:"admin" +TYPE:"cm:content" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fm:post" +(TYPE:"content" OR TYPE:"app:filelink" OR TYPE:"folder")
...
Caused by: org.alfresco.error.AlfrescoRuntimeException: 01080180 Failed to execute search: +PATH:"/app:company_home/st:sites/cm:montblanc/cm:documentLibrary//*" +@cm\:modified:[2021\-2 \-1T00\:00\:00.000 TO 2021\-2\-8T23\:59\:59.999] +@cm\:modifier:"admin" +TYPE:"cm:content" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fm:post" +(TYPE:"content" OR TYPE:"app:filelink" OR TYPE:"folder")
...
Caused by: org.alfresco.repo.search.impl.lucene.LuceneQueryParserException: 01080179 Request failed 500 /solr/alfresco/alfresco?wt=json&fl=DBID%2Cscore&rows=50&df=TEXT&start=0&locale=en_US&alternativeDic=DEFAULT_DICTIONARY&sort=%40cm%3Amodified+desc&fq=%7B%21afts%7DAUTHORITY_FILTER_FROM_JSON&fq=%7B 21afts%7DTENANT_FILTER_FROM_JSON

could you check the script on a VM to see if something has become broken ?

Thanks in advance,
Giuliano

TASK [Create search install directory] Fails

Hi
When running installSearch.yml, it runs tasks/doInstallSearch.yml
that in turn will provide

- name: Create search install directory
  file: path={{ search_install_dir }} state=directory

that ... will FAIL.

TASK [Create search install directory] ************************************************************************************************************************************************************
fatal: [192.168.0.80]: FAILED! => {"changed": false, "msg": "There was an issue creating /opt/alfresco-6.2.0-ga as requested: [Errno 13] Permission denied: b'/opt/alfresco-6.2.0-ga'", "path": "/opt/alfresco-6.2.0-ga/alfresco-search-services"}

the problem seems to me related to the directory position/definition in the var file:

alf_home: "/opt/alfresco"
alf_data: "{{ alf_home }}/alf_data"
alf_install_dir: /opt/alfresco-6.2.0-ga
search_install_dir: '{{ alf_install_dir }}/alfresco-search-services'

In simpler words, it's a matter of file owner/permission
the alfresco user is the owner of the /opt/alfresco folder , and because of that can correctly create any directory he wants inside(under) /opt/alfresco.
BUT to create a sibling directory of /opt/alfresco, i.e. another directory INSIDE /opt (e.g. /opt/alfresco-6.2.0-ga) , the alfresco user should ALSO OWN the /opt directory,
BUT usually this is not the normal situation, and the dir creation is correctly denied.

To let the script work I had to change the owner of /opt to alfresco.... the error vanished.

One quick fix would be to change alf_install_dir into:
alf_install_dir: {{alf_home}}/alfresco-6.2.0-ga
so that search_install_dir could be freely created inside..

Is there any special need to keep the install dir as a SIBLING of /opt/alfresco, (i.e. /opt/alfresco-6.2.0-ga) , instead of the simpler SON /opt/alfresco/alfresco-6.2.0-ga that stays INSIDE /opt/alfresco ?
Can we make the change ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.