Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
php
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
webarch
php
Commits
4ffaf635
Commit
4ffaf635
authored
2 years ago
by
Chris Croome
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
ee86b2e1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Merge Sury
Pipeline
#26111
failed
2 years ago
Stage: lint
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
tasks/conf.yml
+8
-8
8 additions, 8 deletions
tasks/conf.yml
tasks/file_edited.yml
+1
-2
1 addition, 2 deletions
tasks/file_edited.yml
tasks/file_templated.yml
+121
-7
121 additions, 7 deletions
tasks/file_templated.yml
templates/php.j2
+12
-0
12 additions, 0 deletions
templates/php.j2
with
142 additions
and
17 deletions
tasks/conf.yml
+
8
−
8
View file @
4ffaf635
...
...
@@ -193,14 +193,14 @@
var
:
php_conf_files_template
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}0{%
else
%}1{%
endif
%}"
#
- name: Include PHP configuration file templated tasks
#
ansible.builtin.include_tasks: file_templated.yml
#
loop: "{{ php_conf_files_template }}"
#
loop_control:
#
loop_var: php_conf_file
#
when:
#
- php_conf_files_template is defined
#
- php_conf_files_template != []
-
name
:
Include PHP configuration file templated tasks
ansible.builtin.include_tasks
:
file_templated.yml
loop
:
"
{{
php_conf_files_template
}}"
loop_control
:
loop_var
:
php_conf_file
when
:
-
php_conf_files_template is defined
-
php_conf_files_template != []
tags
:
-
php
...
...
This diff is collapsed.
Click to expand it.
tasks/file_edited.yml
+
1
−
2
View file @
4ffaf635
...
...
@@ -33,7 +33,6 @@
-
name
:
Set a fact for the proposed PHP configuration file variables
ansible.builtin.set_fact
:
php_conf_file_proposed_vars
:
"
{{
php_config
|
ansible.builtin.json_query(php_conf_file_proposed_vars_json_query)
}}"
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}0{%
else
%}1{%
endif
%}"
vars
:
php_conf_file_proposed_vars_json_query
:
"
[?state=='present'].files[]|[?path=='{{
php_conf_file
}}'].conf|[0]"
...
...
@@ -47,7 +46,7 @@
var
:
php_conf_file_proposed_vars.keys()
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}1{%
else
%}2{%
endif
%}"
-
name
:
Set fact for PHP configuration file
-
name
:
Set fact
s
for
the
PHP configuration file
ansible.builtin.set_fact
:
php_conf_file_backup
:
"
{{
php_conf_file
|
ansible.builtin.dirname
}}/.{{
php_conf_file
|
ansible.builtin.basename
}}.{{
ansible_date_time.iso8601_basic_short
}}.bak"
php_conf_file_changed
:
false
...
...
This diff is collapsed.
Click to expand it.
tasks/file_templated.yml
+
121
−
7
View file @
4ffaf635
...
...
@@ -8,11 +8,125 @@
#
# You should have received a copy of the GNU General Public License along with the Webarchitects PHP Ansible role. If not, see <https://www.gnu.org/licenses/>.
---
# - name: PHP configuration file templated
# block:
#
# tags:
# - php
# - php_cfg
# - php_conf
-
name
:
PHP configuration file templated
block
:
-
name
:
Set facts for the PHP configuration file
ansible.builtin.set_fact
:
php_conf_file_backup
:
"
{{
php_conf_file
|
ansible.builtin.dirname
}}/.{{
php_conf_file
|
ansible.builtin.basename
}}.{{
ansible_date_time.iso8601_basic_short
}}.bak"
php_conf_file_proposed_vars
:
"
{{
php_config
|
ansible.builtin.json_query(php_conf_file_proposed_vars_json_query)
}}"
php_conf_file_sapi
:
"
{{
php_conf_file
|
ansible.builtin.split(php_file_path_separator)
|
ansible.builtin.json_query('[4]')
}}"
php_conf_file_version
:
"
{{
php_conf_file
|
ansible.builtin.split(php_file_path_separator)
|
ansible.builtin.json_query('[3]')
}}"
vars
:
php_conf_file_proposed_vars_json_query
:
"
[?state=='present'].files[]|[?path=='{{
php_conf_file
}}'].conf|[0]"
-
name
:
Debug the PHP configuration file backup path
ansible.builtin.debug
:
var
:
php_conf_file_backup
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}1{%
else
%}2{%
endif
%}"
-
name
:
Debug the PHP configuration file PHP SAPI
ansible.builtin.debug
:
var
:
php_conf_file_sapi
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}1{%
else
%}2{%
endif
%}"
-
name
:
Debug the PHP configuration file PHP version
ansible.builtin.debug
:
var
:
php_conf_file_version
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}1{%
else
%}2{%
endif
%}"
-
name
:
Debug the proposed PHP configuration file variables
ansible.builtin.debug
:
var
:
php_conf_file_proposed_vars
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}1{%
else
%}2{%
endif
%}"
-
name
:
Debug the proposed PHP configuration file sections
ansible.builtin.debug
:
var
:
php_conf_file_proposed_vars.keys()
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}1{%
else
%}2{%
endif
%}"
-
name
:
File backup present
ansible.builtin.copy
:
src
:
"
{{
php_conf_file
}}"
dest
:
"
{{
php_conf_file_backup
}}"
remote_src
:
true
mode
:
0644
owner
:
root
group
:
root
when
:
php_conf_file in php_conf_files_existing
-
name
:
File templated
ansible.builtin.template
:
src
:
php.j2
dest
:
"
{{
php_conf_file
}}"
mode
:
0644
owner
:
root
group
:
root
register
:
php_conf_file_templated
-
name
:
Test and reload PHP configuration file when file is in a FPM directory
block
:
-
name
:
Test PHP configuration
block
:
-
name
:
PHP FPM configtest
ansible.builtin.command
:
"
php-fpm{{
php_conf_file_version
}}
--test"
check_mode
:
false
changed_when
:
false
register
:
php_fpm_test
failed_when
:
>-
( php_fpm_test.rc != 0 ) or
( "Failed" in php_fpm_test.stderr )
rescue
:
-
name
:
Copy broken PHP configuration file
ansible.builtin.copy
:
src
:
"
{{
php_conf_file
}}"
dest
:
"
{{
php_conf_file_backup
}}.broken"
remote_src
:
true
mode
:
0644
owner
:
root
group
:
root
-
name
:
Copy backup file over edited file as the configuration test failed
ansible.builtin.copy
:
src
:
"
{{
php_conf_file_backup
}}"
dest
:
"
{{
php_conf_file
}}"
remote_src
:
true
mode
:
0644
owner
:
root
group
:
root
-
name
:
Debug PHP configuration file test failure
ansible.builtin.debug
:
var
:
php_fpm_test.stderr_lines
-
name
:
Fail as there was a problem with the updated configuration file
ansible.builtin.fail
:
msg
:
"
The
original
configuration
has
been
restored
and
the
broken
file
is
available
at
{{
php_conf_file_backup
}}.broken"
-
name
:
PHP FPM reloaded
ansible.builtin.service
:
name
:
"
php{{
php_conf_file_version
}}-fpm"
state
:
reloaded
when
:
-
php_conf_file_version in php_ver_installed
-
php_conf_file_templated.changed | bool
-
php_conf_file_sapi is defined
-
php_conf_file_sapi == "fpm"
-
name
:
File backup absent when the PHP configuration file is unchanged
ansible.builtin.file
:
path
:
"
{{
php_conf_file_backup
}}"
state
:
absent
changed_when
:
false
when
:
not php_conf_file_templated.changed | bool
tags
:
-
php
-
php_cfg
-
php_conf
...
This diff is collapsed.
Click to expand it.
templates/php.j2
0 → 100644
+
12
−
0
View file @
4ffaf635
# {{ systemd_ansible_managed }}
{%
for
php_section
in
|
dict2items
%}
[{{ php_section.key }}]
{%
for
php_variable_pair
in
php_section.value
|
dict2items
%}
{{ php_variable_pair.key }}
=
{{ php_variable_pair.value }}
{%
endfor
%}
{%
endfor
%}
# vim: ft=systemd:
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment