Ansible scripts
The panel implements working with scripts based on the popular and convenient Ansible tool.
Below you can find out how to add your own scripts to the panel and see the examples of configuration files.
Add scripts
If you need to add scripts that are not available in Ansible:
- Copy to the required directory created by the ispmanager command, webscripts directory, containing meta-description (webscripts.xml) and script archives (the archive must contain ansible playbook.yml and the necessary auxiliary files).
- Add the appropriate entries to webscripts.xml and attach the script archive.
- In the ispmanager configuration file (path example:
/usr/local/mgr5/etc/ispmgr.conf
), add a line with the WebscriptsRepoUrl parameter and a path to the webscripts directory . - Reboot the server, after that the Web Scripts form (in the Settings section) will display the scripts specified in webscripts.xml.
If the WebscriptsRepoUrl parameter is added, the panel will access only the path specified in it. It works with only one directory at a time.
Examples of configuration files
Example of webscripts.xml:
<doc>
<webscript type="ansible" name="Bitrix">
<settings>
<filename>bitrix.tgz</filename>
<playbook>playbook.yml</playbook>
</settings>
<mgr>
<minimal_version>6.0.0</minimal_version>
</mgr>
<required>
<php version="7.2" max_version="7.4">
<extensions>
<extension name="gd"/>
<extension name="exif"/>
</extensions>
<modes>
<mode name="php_mode_cgi"/>
</modes>
</php>
<database type="mysql" version="5.6"/>
</required>
</webscript>
</doc>
- type – internal script name;
- name – name displayed in the interface;
- filename – name of the archive in the directory. The script will be downloaded and unpacked while the installation is running;
- playbook - the name of the ansible recipe that will be launched for installation;
- minimal_version – minimum ispmanager version for the script usage;
- required – entities required for this script;
- php – PHP version no lower than version and not higher than max_version required;
- extensions – PHP extensions required for the script;
- modes – if set, the script will only work in the listed PHP modes;
- database - A database of type is required, with a server version of at least version;
- sql-mode – mysql modes that need to be enabled for the database server;
- restricted="yes" – means, on the contrary, the script will not work in these modes.
- php – PHP version no lower than version and not higher than max_version required;
Example of Ansible playbook.yml:
- hosts: 127.0.0.1
tasks:
- name: Create a install directory if it does not exist
file:
path: "{{ install_path }}"
state: directory
owner: "{{ user_name }}"
group: "{{ user_name }}"
mode: "0755"
recurse: yes
- name: Download bitrix
get_url:
url: "http://www.1c-bitrix.ru/download/standard_encode.tar.gz"
dest: "{{ install_path }}/standard_encode.tar.gz"
mode: "644"
timeout: 1800
owner: "{{ user_name }}"
group: "{{ user_name }}"
- name: Unpack bitrix archive
unarchive:
src: "{{ install_path }}/standard_encode.tar.gz"
dest: "{{ install_path }}"
remote_src: yes
owner: "{{ user_name }}"
group: "{{ user_name }}"
- name: Set the permissions on Bitrix directories
command: find {{ install_path }} -type d -exec chmod 755 {} \;
- name: Set the permissions for Bitrix files
command: find {{ install_path }} -type f -exec chmod 644 {} \;
- name: Create a directory if it does not exist
file:
path: "{{ install_path }}/bitrix/php_interface"
state: directory
owner: "{{ user_name }}"
group: "{{ user_name }}"
mode: "0755"
- name: copy dbconn.php
template:
src: templates/dbconn.php.j2
dest: "{{ install_path }}/bitrix/php_interface/dbconn.php"
owner: "{{ user_name }}"
group: "{{ user_name }}"
mode: 0644
- name: copy .settings.php
template:
src: templates/.settings.php.j2
dest: "{{ install_path }}/bitrix/.settings.php"
owner: "{{ user_name }}"
group: "{{ user_name }}"
mode: 0644
- name: copy after_connect_d7.php
template:
src: templates/after_connect_d7.php.j2
dest: "{{ install_path }}/bitrix/php_interface/after_connect_d7.php"
owner: "{{ user_name }}"
group: "{{ user_name }}"
mode: 0644
- name: copy after_connect.php
template:
src: templates/after_connect.php.j2
dest: "{{ install_path }}/bitrix/php_interface/after_connect.php"
owner: "{{ user_name }}"
group: "{{ user_name }}"
mode: 0644
- name: Delete archive
file:
path: "{{ install_path }}/standard_encode.tar.gz"
state: absent
Playbook is launched when CMS is installed on the site.
A list of parameters sent to the script::
- user_name – user name;
- install_path – script installation path;
- db_name – database name;
- db_user_name – database user name;
- db_password – database user password;
- db_server – ip and port of connection to the database;
- site_name – domain name of the site;
- site_docroot – root of the site;
- site_php – on/off if PHP is enabled;
- site_php_mode – PHP operating mode;
- site_ssi – on/off if SSI is enabled;
- site_hsts – on/off if HSTS is enabled;
- site_nodejs – on/off if Node.js is enabled;
- site_secure – on/off if SSL is enabled on/off;
- site_ssl_cert – path to the SSL certificate;
- site_email – administrator’s e-mail;
- site_basedir – on/off if open_basedir is enabled;
- site_charset – site encoding.
Also, among the parameters with the site_prefix, there are all fields from webdomain table.
Technical features
- The script runs in the background. Upon completion a notification is displayed to the user;
- /usr/local/mgr5/sbin/webscripts – script execution handler;
- /usr/local/mgr5/var/webscripts.log – the handler log;
- /usr/local/mgr5/var/.webscripts/ – the directory to which the script is downloaded;
- webscript - the name of the table with script descriptions.