voxpupuli / puppet-jira

Atlassian JIRA Puppet Module
https://forge.puppet.com/puppet/jira
Apache License 2.0
62 stars 143 forks source link

Manage web.xml Config #387

Open Kickball opened 3 years ago

Kickball commented 3 years ago

This puppet module templates several of the commonly used config files for Jira, however web.xml is not one of them at the moment.

It would be useful to fix HTTPS redirection (docs) and change the default session timeout (docs).

While it is possible to manage this separately, ideally it would be possible via the puppet-jira module.

I can work on a PR for this if it is desired but wanted to solicit feedback first.

Kickball commented 2 years ago

This workaround isn't suitable for merging into the module as may not work on all operating systems, but can be implemented in a wrapper module without too much trouble.

# Configure HTTP Redirection for Jira
# https://confluence.atlassian.com/adminjiraserver/running-jira-applications-over-ssl-or-https-938847764.html
exec {
    'atlassian-http-redirection':
        # Firstly remove the last line of the config file (the closing web-app tag) then append the redirection config block and the previously removed closing web-app tag.
        command    => "/bin/head -n-1 web.xml | /bin/sponge web.xml && /bin/cat << EOF >> web.xml
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>all-except-attachments</web-resource-name>
            <url-pattern>*.jsp</url-pattern>
            <url-pattern>*.jspa</url-pattern>
            <url-pattern>/browse/*</url-pattern>
            <url-pattern>/issues/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

</web-app>
EOF",
        # Only run the command if the file doesn't already contain the relevant config block. This ensures the idempotence that Puppet requires.
        unless => '/bin/grep "<transport-guarantee>CONFIDENTIAL</transport-guarantee>" web.xml'
        # Replace with the full path if no variable is available. E.g.
        # path => '/jira/atlassian-software-8.22.2-standalone/atlassian-jira/WEB-INF/',
        path   => '${jira_app_dir}/atlassian-jira/WEB-INF/',
        # Ensure that Jira is already configured, otherwise the directory and file will not exist.
        require => Class['jira'];
}