diff --git a/.github/workflows/kitchen.vagrant.yml b/.github/workflows/kitchen.vagrant.yml new file mode 100644 index 0000000..cd21191 --- /dev/null +++ b/.github/workflows/kitchen.vagrant.yml @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +name: 'Kitchen Vagrant (FreeBSD)' +'on': ['push', 'pull_request'] + +env: + KITCHEN_LOCAL_YAML: 'kitchen.vagrant.yml' + +jobs: + test: + runs-on: 'macos-10.15' + strategy: + fail-fast: false + matrix: + instance: + - freebsd-freebsd-122-latest-py3 + - freebsd-freebsd-114-latest-py3 + steps: + - name: 'Check out code' + uses: 'actions/checkout@v2' + - name: 'Set up Bundler cache' + uses: 'actions/cache@v1' + with: + path: 'vendor/bundle' + key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}" + restore-keys: "${{ runner.os }}-gems-" + - name: 'Run Bundler' + run: | + ruby --version + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + - name: 'Run Test Kitchen' + run: 'bundle exec kitchen verify ${{ matrix.instance }}' diff --git a/Gemfile b/Gemfile index c08ad6c..8be107e 100644 --- a/Gemfile +++ b/Gemfile @@ -12,3 +12,7 @@ gem 'kitchen-docker', git: 'https://gitlab.com/saltstack-formulas/infrastructure # rubocop:enable Layout/LineLength gem 'kitchen-inspec', '>= 2.2.1' gem 'kitchen-salt', '>= 0.6.3' + +group :vagrant do + gem 'kitchen-vagrant' +end diff --git a/Gemfile.lock b/Gemfile.lock index d7cbc3b..ef26d96 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -292,6 +292,8 @@ GEM kitchen-salt (0.6.3) hashie (>= 3.5) test-kitchen (>= 1.4) + kitchen-vagrant (1.7.0) + test-kitchen (>= 1.4, < 3) libyajl2 (1.2.0) license-acceptance (1.0.19) pastel (~> 0.7) @@ -525,6 +527,7 @@ DEPENDENCIES kitchen-docker! kitchen-inspec (>= 2.2.1) kitchen-salt (>= 0.6.3) + kitchen-vagrant BUNDLED WITH 2.1.2 diff --git a/kitchen.vagrant.yml b/kitchen.vagrant.yml new file mode 100644 index 0000000..cb9c6d9 --- /dev/null +++ b/kitchen.vagrant.yml @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +driver: + name: vagrant + cache_directory: false + customize: + usbxhci: 'off' + gui: false + linked_clone: true + ssh: + shell: /bin/sh + +platforms: + - name: freebsd-122-latest-py3 + driver: + box: bento/freebsd-12.2 + - name: freebsd-114-latest-py3 + driver: + box: bento/freebsd-11.4 + +provisioner: + salt_install: bootstrap diff --git a/kitchen.yml b/kitchen.yml index 9423c6a..1a5c715 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -455,3 +455,23 @@ suites: verifier: inspec_tests: - path: test/integration/default + - name: freebsd + includes: + - freebsd-122-latest-py3 + - freebsd-114-latest-py3 + provisioner: + state_top: + base: + '*': + - php._mapdata + - php.composer + pillars: + top.sls: + base: + '*': + - php + pillars_from_files: + php.sls: test/salt/pillar/freebsd.sls + verifier: + inspec_tests: + - path: test/integration/default diff --git a/php/composer.sls b/php/composer.sls index 9640537..95537b2 100644 --- a/php/composer.sls +++ b/php/composer.sls @@ -12,14 +12,9 @@ include: - php -{% if grains['os_family'] == 'FreeBSD' %} - - php.filter - - php.hash - - php.json - - php.mbstring - - php.openssl - - php.phar -{% endif %} +{%- for module in php.lookup.get('composer', {}).get('required_modules', []) %} + - php.{{ module }} +{%- endfor %} get-composer: file.managed: diff --git a/php/map.jinja b/php/map.jinja index 516659d..66e2a93 100644 --- a/php/map.jinja +++ b/php/map.jinja @@ -3102,6 +3102,15 @@ 'cli': { 'ini': '/usr/local/etc/php.ini' }, + 'composer': { + 'required_modules': [ + 'filter', + 'json', + 'mbstring', + 'openssl', + 'phar', + ], + }, 'pkgs': { 'apache2': 'mod_php' + freebsd_php_version, 'composer_bin': 'composer', diff --git a/pillar.example b/pillar.example index 73a1909..9676769 100644 --- a/pillar.example +++ b/pillar.example @@ -74,6 +74,16 @@ php: cli: ini: /location/of/php-cli/php.ini + # php.composer + # Some OS need modules to be installed + composer: + required_modules: + - filter + - json + - mbstring + - openssl + - phar + # php-fpm settings fpm: diff --git a/test/integration/default/controls/config_spec.rb b/test/integration/default/controls/config_spec.rb index c20b7ee..42121f7 100644 --- a/test/integration/default/controls/config_spec.rb +++ b/test/integration/default/controls/config_spec.rb @@ -29,6 +29,15 @@ control 'Php configuration' do def test_suse; end + def test_bsd + describe file('/usr/local/bin/composer') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'wheel' } + its('mode') { should cmp '0755' } + end + end + case os[:family] when 'debian' test_debian @@ -36,5 +45,7 @@ control 'Php configuration' do test_redhat when 'suse' test_suse + when 'bsd' + test_bsd end end diff --git a/test/integration/default/controls/package_spec.rb b/test/integration/default/controls/package_spec.rb index e61dc6b..054663e 100644 --- a/test/integration/default/controls/package_spec.rb +++ b/test/integration/default/controls/package_spec.rb @@ -44,6 +44,16 @@ control 'Php package' do end end + def test_bsd + %w[ + php74 php74-filter php74-json php74-mbstring php74-openssl php74-phar + ].each do |pkg| + describe package(pkg) do + it { should be_installed } + end + end + end + case os[:family] when 'debian' test_debian @@ -51,5 +61,7 @@ control 'Php package' do test_redhat when 'suse' test_suse + when 'bsd' + test_bsd end end diff --git a/test/integration/default/controls/service_spec.rb b/test/integration/default/controls/service_spec.rb index 3e1ba7b..4619a0a 100644 --- a/test/integration/default/controls/service_spec.rb +++ b/test/integration/default/controls/service_spec.rb @@ -19,6 +19,8 @@ control 'Php service' do def test_suse; end + def test_bsd; end + case os[:family] when 'debian' test_debian @@ -26,5 +28,7 @@ control 'Php service' do test_redhat when 'suse' test_suse + when 'bsd' + test_bsd end end diff --git a/test/integration/default/files/_mapdata/freebsd-11.yaml b/test/integration/default/files/_mapdata/freebsd-11.yaml new file mode 100644 index 0000000..158feba --- /dev/null +++ b/test/integration/default/files/_mapdata/freebsd-11.yaml @@ -0,0 +1,302 @@ +# yamllint disable rule:indentation rule:line-length +# FreeBSD-11 +--- +values: + apache2: + ini: + opts: {} + settings: {} + cli: + ini: + opts: {} + settings: {} + fpm: + config: + conf: + opts: {} + settings: {} + ini: + opts: {} + settings: {} + pools: + default.conf: + enabled: false + opts: {} + service: + enabled: true + opts: {} + hhvm: + config: + php: + opts: {} + settings: {} + server: + opts: {} + settings: {} + service: + enabled: true + opts: {} + ini: + defaults: + CLI Server: + cli_server.color: 'On' + Date: + date.timezone: America/New_York + Interbase: + ibase.allow_persistent: 1 + ibase.dateformat: '"%Y-%m-%d"' + ibase.max_links: -1 + ibase.max_persistent: -1 + ibase.timeformat: '"%H:%M:%S"' + ibase.timestampformat: '"%Y-%m-%d %H:%M:%S"' + MSSQL: + mssql.allow_persistent: 'On' + mssql.compatibility_mode: 'Off' + mssql.max_links: -1 + mssql.max_persistent: -1 + mssql.min_error_severity: 10 + mssql.min_message_severity: 10 + mssql.secure_connection: 'Off' + MySQL: + mysql.allow_local_infile: 'On' + mysql.allow_persistent: 'On' + mysql.cache_size: '2000' + mysql.connect_timeout: 60 + mysql.max_links: -1 + mysql.max_persistent: -1 + mysql.trace_mode: 'Off' + MySQLi: + mysqli.allow_persistent: 'On' + mysqli.cache_size: 2000 + mysqli.default_port: 3306 + mysqli.max_links: -1 + mysqli.max_persistent: -1 + mysqli.reconnect: 'Off' + ODBC: + odbc.allow_persistent: 'On' + odbc.check_persistent: 'On' + odbc.defaultbinmode: 1 + odbc.defaultlrl: 4096 + odbc.max_links: '-1' + odbc.max_persistent: '-1' + PHP: + allow_url_fopen: 'On' + allow_url_include: 'Off' + asp_tags: 'Off' + auto_globals_jit: 'On' + default_mimetype: '"text/html"' + default_socket_timeout: 60 + disable_functions: + - pcntl_alarm + - pcntl_fork + - pcntl_waitpid + - pcntl_wait + - pcntl_wifexited + - pcntl_wifstopped + - pcntl_wifsignaled + - pcntl_wexitstatus + - pcntl_wtermsig + - pcntl_wstopsig + - pcntl_signal + - pcntl_signal_dispatch + - pcntl_get_last_error + - pcntl_strerror + - pcntl_sigprocmask + - pcntl_sigwaitinfo + - pcntl_sigtimedwait + - pcntl_exec + - pcntl_getpriority + - pcntl_setpriority + display_errors: 'Off' + display_startup_errors: 'Off' + enable_dl: 'Off' + engine: 'On' + error_reporting: + - E_ALL + - ~E_DEPRECATED + - ~E_STRICT + expose_php: 'On' + file_uploads: 'On' + html_errors: 'On' + ignore_repeated_errors: 'Off' + ignore_repeated_source: 'Off' + implicit_flush: 'Off' + log_errors: 'On' + log_errors_max_len: 1024 + max_execution_time: 30 + max_file_uploads: 20 + max_input_nesting_level: 64 + max_input_time: 60 + max_input_vars: 1000 + memory_limit: 128M + output_buffering: 4096 + post_max_size: 8M + precision: 14 + register_argc_argv: 'Off' + report_memleaks: 'On' + request_order: GP + serialize_precision: 17 + short_open_tag: 'Off' + track_errors: 'Off' + upload_max_filesize: 2M + variables_order: GPCS + zend.enable_gc: 'On' + zlib.output_compression: 'Off' + Pdo_mysql: + pdo_mysql.cache_size: 2000 + PostgreSQL: + pgsql.allow_persistent: 'On' + pgsql.auto_reset_persistent: 'Off' + pgsql.ignore_notice: 0 + pgsql.log_notice: 0 + pgsql.max_links: -1 + pgsql.max_persistent: -1 + SQL: + sql.safe_mode: 'Off' + Session: + session.auto_start: 0 + session.bug_compat_42: 'Off' + session.bug_compat_warn: 'Off' + session.cache_expire: '180' + session.cache_limiter: nocache + session.cookie_lifetime: 0 + session.cookie_path: / + session.gc_divisor: 1000 + session.gc_maxlifetime: 1440 + session.gc_probability: 0 + session.hash_bits_per_character: 5 + session.hash_function: 0 + session.name: PHPSESSID + session.save_handler: files + session.serialize_handler: php + session.use_cookies: 1 + session.use_only_cookies: 1 + session.use_strict_mode: 0 + session.use_trans_sid: 0 + url_rewriter.tags: '"a=href,area=href,frame=src,input=src,form=fakeentry"' + Sybase-CT: + sybct.allow_persistent: 'On' + sybct.max_links: -1 + sybct.max_persistent: -1 + sybct.min_client_severity: 10 + sybct.min_server_severity: 10 + Tidy: + tidy.clean_output: 'Off' + bcmath: + bcmath.scale: 0 + ldap: + ldap.max_links: -1 + mail function: + SMTP: localhost + mail.add_x_header: 'On' + mysqlnd: + mysqlnd.collect_memory_statistics: 'Off' + mysqlnd.collect_statistics: 'On' + soap: + soap.wsdl_cache_dir: '"/tmp"' + soap.wsdl_cache_enabled: 1 + soap.wsdl_cache_limit: 5 + soap.wsdl_cache_ttl: 86400 + lookup: + apache2: + ini: /usr/local/etc/php.ini + module_config: /usr/local/etc/apache24/modules.d/050_mod_php.conf + name: apache24 + cli: + ini: /usr/local/etc/php.ini + composer: + required_modules: + - filter + - json + - mbstring + - openssl + - phar + fpm: + conf: /usr/local/etc/php-fpm.conf + defaults: + global: + error_log: log/php-fpm.log + pid: run/php-fpm.pid + include: /usr/local/etc/php-fpm.d/*.conf + group: wheel + ini: /usr/local/etc/php.ini + pools: /usr/local/etc/php-fpm.d + service: php-fpm + user: root + pkgs: + apache2: mod_php74 + cli: php74 + composer_bin: composer + ctype: php74-ctype + curl: php74-curl + dom: php74-dom + fileinfo: php74-fileinfo + filter: php74-filter + fpm: php74 + gd: php74-gd + hash: php74-hash + iconv: php74-iconv + intl: php74-intl + json: php74-json + local_bin: /usr/local/bin + mbstring: php74-mbstring + mcrypt: php74-mcrypt + memcached: php74-pecl-memcached + mysql: php74-mysqli + opcache: php74-opcache + openssl: php74-openssl + pdo: php74-pdo + pdo_mysql: php74-pdo_mysql + pear: php74-pear + phar: php74-phar + php: php74 + posix: php74-posix + session: php74-session + simplexml: php74-simplexml + snmp: php74-snmp + temp_dir: /tmp + tokenizer: php74-tokenizer + xdebug: php74-pecl-xdebug + xml: php74-xml + xmlwriter: php74-xmlwriter + zip: php74-zip + version: + - '7.4' + - '8.0' + xcache: + ini: + defaults: + xcache: + xcache.cacher: 'On' + xcache.coredump_directory: '""' + xcache.coredump_type: '0' + xcache.count: '1' + xcache.disable_on_crash: 'Off' + xcache.experimental: 'Off' + xcache.gc_interval: '0' + xcache.mmap_path: '"/dev/zero"' + xcache.optimizer: 'Off' + xcache.readonly_protection: 'Off' + xcache.shm_scheme: '"mmap"' + xcache.size: 60M + xcache.slots: 8K + xcache.stat: 'On' + xcache.ttl: '0' + xcache.var_count: '1' + xcache.var_gc_interval: '300' + xcache.var_maxttl: '0' + xcache.var_namespace: '""' + xcache.var_namespace_mode: '0' + xcache.var_size: 4M + xcache.var_slots: 8K + xcache.var_ttl: '0' + xcache-common: + extension: xcache.so + xcache.admin: + xcache.admin.enable_auth: 'On' + xcache.coverager: + xcache.coveragedump_directory: '""' + xcache.coverager: 'Off' + xcache.coverager_autostart: 'On' + opts: {} + settings: {} diff --git a/test/integration/default/files/_mapdata/freebsd-12.yaml b/test/integration/default/files/_mapdata/freebsd-12.yaml new file mode 100644 index 0000000..10ec9d0 --- /dev/null +++ b/test/integration/default/files/_mapdata/freebsd-12.yaml @@ -0,0 +1,302 @@ +# yamllint disable rule:indentation rule:line-length +# FreeBSD-12 +--- +values: + apache2: + ini: + opts: {} + settings: {} + cli: + ini: + opts: {} + settings: {} + fpm: + config: + conf: + opts: {} + settings: {} + ini: + opts: {} + settings: {} + pools: + default.conf: + enabled: false + opts: {} + service: + enabled: true + opts: {} + hhvm: + config: + php: + opts: {} + settings: {} + server: + opts: {} + settings: {} + service: + enabled: true + opts: {} + ini: + defaults: + CLI Server: + cli_server.color: 'On' + Date: + date.timezone: America/New_York + Interbase: + ibase.allow_persistent: 1 + ibase.dateformat: '"%Y-%m-%d"' + ibase.max_links: -1 + ibase.max_persistent: -1 + ibase.timeformat: '"%H:%M:%S"' + ibase.timestampformat: '"%Y-%m-%d %H:%M:%S"' + MSSQL: + mssql.allow_persistent: 'On' + mssql.compatibility_mode: 'Off' + mssql.max_links: -1 + mssql.max_persistent: -1 + mssql.min_error_severity: 10 + mssql.min_message_severity: 10 + mssql.secure_connection: 'Off' + MySQL: + mysql.allow_local_infile: 'On' + mysql.allow_persistent: 'On' + mysql.cache_size: '2000' + mysql.connect_timeout: 60 + mysql.max_links: -1 + mysql.max_persistent: -1 + mysql.trace_mode: 'Off' + MySQLi: + mysqli.allow_persistent: 'On' + mysqli.cache_size: 2000 + mysqli.default_port: 3306 + mysqli.max_links: -1 + mysqli.max_persistent: -1 + mysqli.reconnect: 'Off' + ODBC: + odbc.allow_persistent: 'On' + odbc.check_persistent: 'On' + odbc.defaultbinmode: 1 + odbc.defaultlrl: 4096 + odbc.max_links: '-1' + odbc.max_persistent: '-1' + PHP: + allow_url_fopen: 'On' + allow_url_include: 'Off' + asp_tags: 'Off' + auto_globals_jit: 'On' + default_mimetype: '"text/html"' + default_socket_timeout: 60 + disable_functions: + - pcntl_alarm + - pcntl_fork + - pcntl_waitpid + - pcntl_wait + - pcntl_wifexited + - pcntl_wifstopped + - pcntl_wifsignaled + - pcntl_wexitstatus + - pcntl_wtermsig + - pcntl_wstopsig + - pcntl_signal + - pcntl_signal_dispatch + - pcntl_get_last_error + - pcntl_strerror + - pcntl_sigprocmask + - pcntl_sigwaitinfo + - pcntl_sigtimedwait + - pcntl_exec + - pcntl_getpriority + - pcntl_setpriority + display_errors: 'Off' + display_startup_errors: 'Off' + enable_dl: 'Off' + engine: 'On' + error_reporting: + - E_ALL + - ~E_DEPRECATED + - ~E_STRICT + expose_php: 'On' + file_uploads: 'On' + html_errors: 'On' + ignore_repeated_errors: 'Off' + ignore_repeated_source: 'Off' + implicit_flush: 'Off' + log_errors: 'On' + log_errors_max_len: 1024 + max_execution_time: 30 + max_file_uploads: 20 + max_input_nesting_level: 64 + max_input_time: 60 + max_input_vars: 1000 + memory_limit: 128M + output_buffering: 4096 + post_max_size: 8M + precision: 14 + register_argc_argv: 'Off' + report_memleaks: 'On' + request_order: GP + serialize_precision: 17 + short_open_tag: 'Off' + track_errors: 'Off' + upload_max_filesize: 2M + variables_order: GPCS + zend.enable_gc: 'On' + zlib.output_compression: 'Off' + Pdo_mysql: + pdo_mysql.cache_size: 2000 + PostgreSQL: + pgsql.allow_persistent: 'On' + pgsql.auto_reset_persistent: 'Off' + pgsql.ignore_notice: 0 + pgsql.log_notice: 0 + pgsql.max_links: -1 + pgsql.max_persistent: -1 + SQL: + sql.safe_mode: 'Off' + Session: + session.auto_start: 0 + session.bug_compat_42: 'Off' + session.bug_compat_warn: 'Off' + session.cache_expire: '180' + session.cache_limiter: nocache + session.cookie_lifetime: 0 + session.cookie_path: / + session.gc_divisor: 1000 + session.gc_maxlifetime: 1440 + session.gc_probability: 0 + session.hash_bits_per_character: 5 + session.hash_function: 0 + session.name: PHPSESSID + session.save_handler: files + session.serialize_handler: php + session.use_cookies: 1 + session.use_only_cookies: 1 + session.use_strict_mode: 0 + session.use_trans_sid: 0 + url_rewriter.tags: '"a=href,area=href,frame=src,input=src,form=fakeentry"' + Sybase-CT: + sybct.allow_persistent: 'On' + sybct.max_links: -1 + sybct.max_persistent: -1 + sybct.min_client_severity: 10 + sybct.min_server_severity: 10 + Tidy: + tidy.clean_output: 'Off' + bcmath: + bcmath.scale: 0 + ldap: + ldap.max_links: -1 + mail function: + SMTP: localhost + mail.add_x_header: 'On' + mysqlnd: + mysqlnd.collect_memory_statistics: 'Off' + mysqlnd.collect_statistics: 'On' + soap: + soap.wsdl_cache_dir: '"/tmp"' + soap.wsdl_cache_enabled: 1 + soap.wsdl_cache_limit: 5 + soap.wsdl_cache_ttl: 86400 + lookup: + apache2: + ini: /usr/local/etc/php.ini + module_config: /usr/local/etc/apache24/modules.d/050_mod_php.conf + name: apache24 + cli: + ini: /usr/local/etc/php.ini + composer: + required_modules: + - filter + - json + - mbstring + - openssl + - phar + fpm: + conf: /usr/local/etc/php-fpm.conf + defaults: + global: + error_log: log/php-fpm.log + pid: run/php-fpm.pid + include: /usr/local/etc/php-fpm.d/*.conf + group: wheel + ini: /usr/local/etc/php.ini + pools: /usr/local/etc/php-fpm.d + service: php-fpm + user: root + pkgs: + apache2: mod_php74 + cli: php74 + composer_bin: composer + ctype: php74-ctype + curl: php74-curl + dom: php74-dom + fileinfo: php74-fileinfo + filter: php74-filter + fpm: php74 + gd: php74-gd + hash: php74-hash + iconv: php74-iconv + intl: php74-intl + json: php74-json + local_bin: /usr/local/bin + mbstring: php74-mbstring + mcrypt: php74-mcrypt + memcached: php74-pecl-memcached + mysql: php74-mysqli + opcache: php74-opcache + openssl: php74-openssl + pdo: php74-pdo + pdo_mysql: php74-pdo_mysql + pear: php74-pear + phar: php74-phar + php: php74 + posix: php74-posix + session: php74-session + simplexml: php74-simplexml + snmp: php74-snmp + temp_dir: /tmp + tokenizer: php74-tokenizer + xdebug: php74-pecl-xdebug + xml: php74-xml + xmlwriter: php74-xmlwriter + zip: php74-zip + version: + - '7.4' + - '8.0' + xcache: + ini: + defaults: + xcache: + xcache.cacher: 'On' + xcache.coredump_directory: '""' + xcache.coredump_type: '0' + xcache.count: '1' + xcache.disable_on_crash: 'Off' + xcache.experimental: 'Off' + xcache.gc_interval: '0' + xcache.mmap_path: '"/dev/zero"' + xcache.optimizer: 'Off' + xcache.readonly_protection: 'Off' + xcache.shm_scheme: '"mmap"' + xcache.size: 60M + xcache.slots: 8K + xcache.stat: 'On' + xcache.ttl: '0' + xcache.var_count: '1' + xcache.var_gc_interval: '300' + xcache.var_maxttl: '0' + xcache.var_namespace: '""' + xcache.var_namespace_mode: '0' + xcache.var_size: 4M + xcache.var_slots: 8K + xcache.var_ttl: '0' + xcache-common: + extension: xcache.so + xcache.admin: + xcache.admin.enable_auth: 'On' + xcache.coverager: + xcache.coveragedump_directory: '""' + xcache.coverager: 'Off' + xcache.coverager_autostart: 'On' + opts: {} + settings: {} diff --git a/test/salt/pillar/freebsd.sls b/test/salt/pillar/freebsd.sls new file mode 100644 index 0000000..71eb52e --- /dev/null +++ b/test/salt/pillar/freebsd.sls @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +php: + version: + # - '7.3' + - '7.4' + - '8.0'