Solr Ansible在欺骗我
我有一个可行的剧本,可以在我的SOLR实例上修复损坏的XML:Solr Ansible在欺骗我,solr,ansible,jenkins-plugins,Solr,Ansible,Jenkins Plugins,我有一个可行的剧本,可以在我的SOLR实例上修复损坏的XML: - hosts: host-solr-master, host-solr-repeater become: true become_user: user tasks: - name: Fixing corrupted wc-search.xml lineinfile: path: '{{ solr_catalog_config_dir }}/wc-search.xml' regexp
- hosts: host-solr-master, host-solr-repeater
become: true
become_user: user
tasks:
- name: Fixing corrupted wc-search.xml
lineinfile:
path: '{{ solr_catalog_config_dir }}/wc-search.xml'
regexp: '{{ item.regexp }}'
line: '{{ item.line }}'
state: '{{ item.state }}'
with_items:
- { regexp: '<\!DOCTYPE.*', line: '', state: 'absent' }
- { regexp: '\]>', line: '', state: 'absent' }
- { regexp: '<_config:cores.*', line: '<_config:cores>', state: 'present' }
- name: Preview the changed wc-search.xml
shell: cat '{{ solr_catalog_config_dir }}/wc-search.xml'
-主机:主机solr主机、主机solr中继器
变成:真的
成为用户:用户
任务:
-名称:修复损坏的wc-search.xml
线条填充:
路径:{{solr\u catalog\u config\u dir}}/wc search.xml'
regexp:“{item.regexp}}”
行:“{item.line}”
状态:“{item.state}}”
有以下项目:
-{regexp:'',行:'',状态:'缺席'}
-{regexp:'',u'line':u'',u'state':u'缺席'})=>{
“备份”:“,
“更改”:错误,
“已找到”:0,
“项目”:{
“行”:“,
“regexp”:“\\]>”,
“状态”:“缺席”
}
}
已更改:[hostname.repeater]=>(项={u'regexp':u'\\]>',u'line':u'',u'state':u'缺席'})=>{
“备份”:“,
“改变”:对,
“发现”:1,
“项目”:{
“行”:“,
“regexp”:“\\]>”,
“状态”:“缺席”
}
}
味精:
1条线路已拆除
已更改:[hostname.repeater]=>(item={u'regexp]:u'当存在错误时,为什么要使用regex?文件中有一些垃圾,它不符合有效的XML,因此这里使用regex更好
TASK [Fixing corrupted wc-search.xml] ******************************************
ok: [hostname.master] => (item={u'regexp': u'<\\!DOCTYPE.*', u'line': u'', u'state': u'absent'}) => {
"backup": "",
"changed": false,
"found": 0,
"item": {
"line": "",
"regexp": "<\\!DOCTYPE.*",
"state": "absent"
}
}
changed: [hostname.repeater] => (item={u'regexp': u'<\\!DOCTYPE.*', u'line': u'', u'state': u'absent'}) => {
"backup": "",
"changed": true,
"found": 1,
"item": {
"line": "",
"regexp": "<\\!DOCTYPE.*",
"state": "absent"
}
}
MSG:
1 line(s) removed
ok: [hostname.master] => (item={u'regexp': u'\\]>', u'line': u'', u'state': u'absent'}) => {
"backup": "",
"changed": false,
"found": 0,
"item": {
"line": "",
"regexp": "\\]>",
"state": "absent"
}
}
changed: [hostname.repeater] => (item={u'regexp': u'\\]>', u'line': u'', u'state': u'absent'}) => {
"backup": "",
"changed": true,
"found": 1,
"item": {
"line": "",
"regexp": "\\]>",
"state": "absent"
}
}
MSG:
1 line(s) removed
changed: [hostname.repeater] => (item={u'regexp': u'<_config:cores.*', u'line': u'<_config:cores>', u'state': u'present'}) => {
"backup": "",
"changed": true,
"item": {
"line": "<_config:cores>",
"regexp": "<_config:cores.*",
"state": "present"
}
}
MSG:
line replaced
ok: [hostname.master] => (item={u'regexp': u'<_config:cores.*', u'line': u'<_config:cores>', u'state': u'present'}) => {
"backup": "",
"changed": false,
"item": {
"line": "<_config:cores>",
"regexp": "<_config:cores.*",
"state": "present"
}
}
TASK [Preview the changed wc-search.xml] ***************************************
changed: [hostname.repeater] => {
"changed": true,
"cmd": "cat 'PATH_TO/wc-search.xml'",
"delta": "0:00:00.023935",
"end": "2020-03-16 10:37:23.424572",
"rc": 0,
"start": "2020-03-16 10:37:23.400637"
}
STDOUT:
<?xml version="1.0" encoding="UTF-8"?>
<_config:search-config
xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-search.xsd ">
<_config:server name="BasicConfiguration">
<_config:embedded/>
</_config:server>
<_config:cores>
...
</_config:cores>
</_config:search-config>
changed: [hostname.master] => {
"changed": true,
"cmd": "cat 'PATH_TO/wc-search.xml'",
"delta": "0:00:00.036818",
"end": "2020-03-16 10:37:23.560608",
"rc": 0,
"start": "2020-03-16 10:37:23.523790"
}
STDOUT:
<?xml version="1.0" encoding="UTF-8"?>
<_config:search-config
xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-search.xsd ">
<_config:server name="BasicConfiguration">
<_config:embedded/>
</_config:server>
<_config:cores>
...
</_config:cores>
...
</_config:search-config>