fix ansible-lint errors

This commit is contained in:
Sergey Malyuk
2025-12-19 12:09:28 +03:00
parent 6876365108
commit 2ccf6be8b7
10 changed files with 672 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
---
- name: Converge
hosts: all
roles:
# - role: oneget
# oneget_version: 0.6.0
- role: genlab.common.platform1c
platform1c_version: "8.3.26.1540" # required
platform1c_config: "{{ role_path }}/molecule/default/files/test.yaml" # required
platform1c_admin_pw_path: "secrets/platform1c.yaml" # required
platform1c_oneget_pw_path: "secrets/oneget.yaml" # required if using oneget
platform1c_platformfile: "{{ role_path }}/molecule/default/files/server64_with_all_clients_8_3_26_1540.zip" # if platfrom1c_download_methond == manual
platform1c_download_method: 'manual' # required. manual or oneget

View File

@@ -0,0 +1,16 @@
---
platform1c_pubs: # all fields are required.
- path: "/www/root/zup/" # mind the trailing / at the end.
name: "zup"
odata_enabled: true # REST API
ws_enabled: true # sync between different products (e.g. zup<->buh sync).
- path: "/www/root/buh/"
name: "buh"
odata_enabled: true
ws_enabled: false
- path: "/www/root/doc/"
name: "doc"
odata_enabled: false
ws_enabled: false

View File

@@ -0,0 +1,22 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: ubuntu
image: geerlingguy/docker-ubuntu2204-ansible:latest
pre_build_image: true
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
provisioner:
name: ansible
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .

View File

@@ -0,0 +1,15 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: "Get 1C version"
register: platform1c_version_installed
changed_when: false
ansible.builtin.command:
cmd: "ls /opt/1cv8/x86_64"
- name: Read 1C version
ansible.builtin.debug:
msg: "{{ platform1c_version_installed.stdout }}"

View File

@@ -0,0 +1,3 @@
---
platform1c_oneget_user: user
platform1c_oneget_pw: password

View File

@@ -0,0 +1,3 @@
---
platform1c_admin_user: "Администратор"
platform1c_admin_pw: 12345

View File

@@ -0,0 +1,314 @@
---
# tasks file for platform1c
# example platform download with shell
# export ONEC_USERNAME=user
# export ONEC_PASSWORD=password
# oneget get --path ./tmp/dist/ platform@8.3.18.1334
# current 1C version (by systemd service):
# systemctl status | grep srv1cv8-8.3 | cut -d "-" -f 2 | cut -d "@" -f 1 | sed '/^$/d'
# or just look at /opt/1cv8/...
- name: "Verify that required variables are defined"
ansible.builtin.assert:
that:
- required_var is defined
- required_var | length > 0
- required_var != None
fail_msg: "{{ required_var }} needs to be set for the role to work"
success_msg: "Required variable {{ required_var }} is defined"
loop_control:
loop_var: required_var
with_items:
- platform1c_version
- platform1c_config
- platform1c_admin_pw_path
- platform1c_oneget_pw_path
- platform1c_download_method
- name: "Verify that platform1c_download_method are defined correct"
ansible.builtin.assert:
that:
- platform1c_download_method == 'manual' or (platform1c_download_method == 'oneget')
fail_msg: "{{ platform1c_download_method }} needs to be set for the role to work"
success_msg: "Method {{ platform1c_download_method }} is defined"
- name: "Install unzip, apache2, ufw"
ansible.builtin.apt:
name:
- unzip
- apache2
- ufw
state: present
update_cache: true
- name: "Deny access to 1c platform ports with ufw"
community.general.ufw:
rule: deny
port: "{{ item.port }}"
loop:
- { port: "1545" } # 1c ras
- { port: "1540" } # 1c server agent
- { port: "1541" } # 1c server manager
- name: "Deny access to 1c platform ports with ufw (1c workers)"
community.general.ufw:
rule: deny
port: 1560:1591 # 1c server workers
proto: tcp
- name: "Enable ufw"
community.general.ufw:
state: enabled
- name: "Read variables from the configuration file"
ansible.builtin.include_vars:
file: "{{ platform1c_config }}"
- name: "Populate service facts"
ansible.builtin.service_facts:
- name: "Parse active platform 1C version"
ansible.builtin.set_fact:
platform1c_version_active: "{{ ansible_facts.services
| dict2items
| selectattr('value.name', 'search', 'srv1cv8-')
| map(attribute='value.name')
| regex_search('[0-9].[0-9].[0-9]{2}.[0-9]{4}') }}" # using regexp to parse 8.3.12.1234
failed_when: false # Handled follows after
- name: "Get platform1c_versions_installed"
ansible.builtin.find:
paths: "/opt/1cv8/x86_64/"
recurse: true
file_type: directory
register: platform1c_versions_installed
- name: "Check the requested 1C version"
block:
- name: "Assert version correctness"
ansible.builtin.assert:
that: "platform1c_version in platform1c_version_active"
success_msg: "Expected 1C version available ({{ platform1c_version_active }})"
fail_msg: "Expected version '{{ platform1c_version }}'; available is '{{ platform1c_version_active }}'"
rescue:
- name: "Using manual method"
when: platform1c_download_method == 'manual'
block:
- name: "Create tmp archive dir"
ansible.builtin.file:
path: /root/platform83/{{ platform1c_version }}
state: directory
owner: root
group: root
recurse: true
mode: '0755'
- name: "Copy platform file from controller"
ansible.builtin.copy:
src: "{{ platform1c_platformfile }}"
dest: /root/platform83/{{ platform1c_version }}/server64_with_all_clients_{{ platform1c_version | replace('.', '_') }}.zip
owner: "root"
mode: '0755'
- name: "Using manual oneget"
when: platform1c_download_method == 'oneget'
block:
- name: "Get oneget credentials"
ansible.builtin.include_vars:
file: "{{ platform1c_oneget_pw_path }}"
- name: "Download 1C platform (version - {{ platform1c_version }})"
environment:
PATH: "/opt/oneget:{{ ansible_env.PATH }}"
ONEC_USERNAME: "{{ platform1c_oneget_user }}"
ONEC_PASSWORD: "{{ platform1c_oneget_pw }}"
ansible.builtin.command:
cmd: "oneget get --path /root/ --filter platform=server64_with_all_clients platform:linux.full.x64@{{ platform1c_version }}"
creates: "/root/platform83/{{ platform1c_version }}/server64_with_all_clients_{{ platform1c_version | replace('.', '_') }}.zip"
- name: "Create tmp install dir"
ansible.builtin.file:
path: /root/tmp1c
state: directory
owner: root
group: root
mode: '0755'
- name: "Unarchive distro"
ansible.builtin.unarchive:
src: /root/platform83/{{ platform1c_version }}/server64_with_all_clients_{{ platform1c_version | replace('.', '_') }}.zip
dest: /root/tmp1c
remote_src: true
- name: "Install 1C platform"
ansible.builtin.command:
cmd: "/root/tmp1c/setup-full-{{ platform1c_version }}-x86_64.run --mode unattended --enable-components ws,server,ru"
creates: "/opt/1cv8/x86_64/{{ platform1c_version }}"
# https://its.1c.ru/db/v8324doc#bookmark:adm:TI000001075
- name: "Install 1C clients"
ansible.builtin.command:
cmd: "/root/tmp1c/all-clients-distr-{{ platform1c_version }}-x86_64.run --mode unattended"
creates: "/opt/1cv8/x86_64/{{ platform1c_version }}/distr/linux64tc.zip"
- name: "Stop and disable current 1C platform"
ansible.builtin.systemd_service:
name: "srv1cv8-{{ platform1c_version_active }}@default.service"
state: stopped
enabled: false
when: platform1c_version_active is defined
failed_when: false # if exists. The service name contains the version, it is not possible to get the state of the service in a safe way.
- name: "Stop and disable current 1C rac"
ansible.builtin.systemd_service:
name: "ras-{{ platform1c_version_active }}"
state: stopped
enabled: false
when: platform1c_version_active is defined
failed_when: false # if exists. The service name contains the version, it is not possible to get the state of the service in a safe way.
- name: "Copy new 1C platform service"
ansible.builtin.copy:
src: /opt/1cv8/x86_64/{{ platform1c_version }}/srv1cv8-{{ platform1c_version }}@.service
dest: /etc/systemd/system/srv1cv8-{{ platform1c_version }}@.service
owner: root
group: root
mode: '0755'
remote_src: true
- name: "Copy new 1C ras service"
ansible.builtin.copy:
src: /opt/1cv8/x86_64/{{ platform1c_version }}/ras-{{ platform1c_version }}.service
dest: /etc/systemd/system/ras-{{ platform1c_version }}.service
owner: root
group: root
mode: '0755'
remote_src: true
- name: "Enable ans start new 1С ras service"
ansible.builtin.systemd_service:
name: "ras-{{ platform1c_version }}"
state: started
enabled: true
- name: "Enable and start new 1C platform"
ansible.builtin.systemd_service:
name: "srv1cv8-{{ platform1c_version }}@default.service"
state: started
enabled: true
- name: "Remove old installation"
ansible.builtin.command:
cmd: "{{ item }}/unistaller-full"
removes: "{{ item }}"
loop: "{{ platform1c_versions_installed.files }}"
when: "platform1c_versions_installed.files | length > 0"
poll: 0 # Just make it async
failed_when: false # if exists
- name: "Clear installed unarchived 1C platform"
ansible.builtin.file:
path: "/root/tmp1c/"
state: absent
poll: 0 # Just make it async
- name: "Clear installed 1C platform archive"
ansible.builtin.file:
path: "/root/platform83/"
state: absent
poll: 0 # Just make it async
- name: "Delete old 1C platform service"
ansible.builtin.file:
path: "/etc/systemd/system/srv1cv8-{{ platform1c_version_active }}@.service"
state: absent
when: platform1c_version_active is defined
poll: 0 # Just make it async
- name: "Delete old 1C ras service"
ansible.builtin.file:
path: "/etc/systemd/system/ras-{{ platform1c_version_active }}.service"
state: absent
when: platform1c_version_active is defined
poll: 0 # Just make it async
- name: "Create 1C cluster user (if first install)"
when: "platform1c_versions_installed.files | length == 0"
block:
- name: "Get 1С server credentials"
ansible.builtin.include_vars:
file: "{{ platform1c_admin_pw_path }}"
- name: "Start 1c ras service"
ansible.builtin.systemd_service:
name: "ras-{{ platform1c_version }}"
state: started
enabled: true
- name: "Create 1c server agent admin user"
ansible.builtin.command:
cmd: "/opt/1cv8/x86_64/{{ platform1c_version }}/rac agent admin register --name={{ platform1c_admin_user }} --pwd={{ platform1c_admin_pw }} --auth=pwd"
changed_when: false
- name: "Get 1c cluster info"
ansible.builtin.shell:
cmd: "set -o pipefail && cat /home/usr1cv8/.1cv8/1C/1cv8/1cv8wsrv.lst"
executable: /bin/bash
changed_when: false
register: platform1c_1cv8wsrv
- name: "Parse 1c cluster id"
ansible.builtin.set_fact:
platform1c_cluster: "{{ platform1c_1cv8wsrv | regex_search('(?<={)[0-z]{8}-[0-z]{4}-[0-z]{4}-[0-z]{4}-[0-z]{12}(?=,)') }}"
- name: "Create 1c server cluster admin user"
ansible.builtin.command:
cmd: "/opt/1cv8/x86_64/{{ platform1c_version }}/rac cluster admin register \
--cluster={{ platform1c_cluster }} --pwd={{ platform1c_admin_pw }} \
--name={{ platform1c_admin_user }} --agent-user={{ platform1c_admin_user }} \
--agent-pwd={{ platform1c_admin_pw }} --auth=pwd"
changed_when: false
# - name: "Stop 1c ras service"
# ansible.builtin.systemd_service:
# name: "ras-{{ platform1c_version }}"
# state: stopped
# enabled: false
- name: "Create/update apache2 config"
ansible.builtin.template:
src: apache2.conf.j2
dest: /etc/apache2/apache2.conf
owner: root
group: root
mode: '0755'
register: platform1c_apache2config
- name: "Create 1C publications dirs"
ansible.builtin.file:
path: "{{ item.path }}"
owner: root
group: root
state: directory
mode: '0755'
loop: "{{ platform1c_pubs }}"
register: platform1c_pubsdirs
- name: "Create/update 1C publications configs"
ansible.builtin.template:
src: default.vrd.j2
dest: "{{ item.path }}/default.vrd"
owner: root
group: root
mode: '0755'
loop: "{{ platform1c_pubs }}"
register: platform1c_pubsconfigs
- name: "Restart apache"
ansible.builtin.systemd_service:
name: apache2
state: restarted
daemon_reload: true
when: platform1c_pubsdirs.changed or platform1c_pubsdirs.changed or platform1c_pubsconfigs.changed

View File

@@ -0,0 +1,252 @@
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.
# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
# /etc/apache2/
# |-- apache2.conf
# | `-- ports.conf
# |-- mods-enabled
# | |-- *.load
# | `-- *.conf
# |-- conf-enabled
# | `-- *.conf
# `-- sites-enabled
# `-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
# together by including all remaining configuration files when starting up the
# web server.
#
# * ports.conf is always included from the main configuration file. It is
# supposed to determine listening ports for incoming connections which can be
# customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
# directories contain particular configuration snippets which manage modules,
# global configuration fragments, or virtual host configurations,
# respectively.
#
# They are activated by symlinking available configuration files from their
# respective *-available/ counterparts. These should be managed by using our
# helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
# their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
# the default configuration, apache2 needs to be started/stopped with
# /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
# work with the default configuration.
# Global configuration
#
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE! If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"
#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default
#
# The directory where shm and other runtime files will be stored.
#
DefaultRuntimeDir ${APACHE_RUN_DIR}
#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}
#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100
#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log
#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn
# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
## 1c publication
#Alias "/zup" "/www/root/zup/"
#<Directory "/www/root/zup/">
# AllowOverride All
# Options None
# Require all granted
# SetHandler 1c-application
# ManagedApplicationDescriptor "/www/root/zup/default.vrd"
#</Directory>
{% for pub in platform1c_pubs %}
# 1c publication
Alias "/{{ pub.name }}" "{{ pub.path }}"
<Directory "{{ pub.path }}">
AllowOverride All
Options None
Require all granted
SetHandler 1c-application
ManagedApplicationDescriptor "{{ pub.path }}default.vrd"
</Directory>
{% endfor %}
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
LoadModule _1cws_module "/opt/1cv8/x86_64/{{ platform1c_version }}/wsap24.so"

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<point xmlns="http://v8.1c.ru/8.2/virtual-resource-system"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
base="/{{ item.name }}"
ib="Srvr=localhost;ref={{ item.name }}"
pubdstlin32="/opt/1cv8/x86_64/{{ platform1c_version }}/distr/linux32tc.zip"
pubdstlin64="/opt/1cv8/x86_64/{{ platform1c_version }}/distr/linux64tc.zip"
pubdstmac64="/opt/1cv8/x86_64/{{ platform1c_version }}/distr/macOS64tc.zip"
pubdstwin32="/opt/1cv8/x86_64/{{ platform1c_version }}/distr/windows32tc.zip"
pubdstwin64="/opt/1cv8/x86_64/{{ platform1c_version }}/distr/windows64tc.zip">
{% if item.ws_enabled %}
<ws pointEnableCommon="true"/>
{% else %}
<ws pointEnableCommon="false"/>
{% endif %}
{% if item.odata_enabled %}
<standardOdata enable="true"
reuseSessions="autouse"
sessionMaxAge="20"
poolSize="10"
poolTimeout="5"/>
{% else %}
<standardOdata enable="false"
reuseSessions="autouse"
sessionMaxAge="20"
poolSize="10"
poolTimeout="5"/>
{% endif %}
<analytics enable="false"/>
</point>

View File

@@ -0,0 +1,2 @@
---
# vars file for oneget