cmprescott / ansible-xml Goto Github PK
View Code? Open in Web Editor NEWA module to manage various properties of XML documents
Home Page: https://galaxy.ansible.com/cmprescott/xml/
License: GNU General Public License v3.0
A module to manage various properties of XML documents
Home Page: https://galaxy.ansible.com/cmprescott/xml/
License: GNU General Public License v3.0
Hi,
I know that is not really an issue, mostly a future request. Is there any plan of adding the xml module in the Ansible Galaxy?
Thank you for this nice module,
Cheers,
Vasilis
Seeking to add match count function and support for strings as opposed to merely files.
Hi,
While trying to save the value with value="<![CDATA[{{ mysql_db_password }}]]>"
, the module is encoding the tags with <![CDATA[...]]>
.
Is there any way to allow such tags?
Thanks,
Razvan
I am trying out the first example in the Examples section:
Remove the subjective attribute of the rating element:
xml: file=/foo/bar.xml xpath=/business/rating/@subjective ensure=absent
My error message:
msg: Couldn't delete xpath target: /business/rating/@subjective ('_ElementStringResult' object has no attribute 'attrname')
Here is where I think it is failing.
There is a test file Here but I haven't spent time to run the tests.
The spec file states that it is on version 0.3.1, but the releases section is on section 0.3.4
I know this isn't a huge deal, but I am building this package using the spec file and I want to verify that the spec file is up to date with the latest requirements, version, etc for this package.
I am attempting to write a playbook for Syncthing and use ansible-xml for managing the config file.
However I seem to be having issues when it comes to attributes.
I have the following task, which I would expect to set the enabled
attribute to yourmom
but it does nothing.
- name: Config | Enable GUI
xml:
file: "{{st_config}}"
xpath: /configuration/gui/@enabled
value: yourmom
I know that st_config
is correct, because this task works just fine:
xml:
file: "{{st_config}}"
xpath: /configuration/gui/address
value: 0.0.0.0:8080
I am also having trouble extracting attribute values via a register
command, that will crash the entire run (rather than failing silently). I was going to enter a ticket for it, however I now wonder if my syntax is incorrect.
Given a call like this:
- xml: file=~user/data.xml ...
the following error occurs:
The target XML source does not exist: ~user/data.xml
even though built-in Ansible modules correctly expand ~user
to the correct thing (which may not necessarily be /home/user
).
Hello!
Thank you for this great module!
However, I'm trying to use it with ansible 2.0.0.2
and getting the following error:
ERROR! 'version' is not a valid attribute for a RoleMetadata
The error appears to have been in '/etc/ansible/roles/cmprescott.xml/meta/main.yml': line 2, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
galaxy_info:
^ here
Looks like metadata file has incorrect structure according to the latest Ansible requirements.
I've removed version
field from the /etc/ansible/roles/cmprescott.xml/meta/main.yml
file on my local machine and it helped.
Could you please fix this in the repo? Thank you!
Cheers!
Say you have an XML like this:
<domain> <configs > <config name="server"> <java-config> <jvm-options>Some option</jvm-options> </java-config> </config> <config name="something"> <java-config> <jvm-options>another option</jvm-options> </java-config> </config> </configs> </domain>
How do I get the module to only modify the first element?
I'm new to parsing XML, so I may have my terms conflated and not know what the hell I'm talking about.... But I have a xml file like this:
<configuration>
<property>
<name>foo1</name>
<value>bar</value>
</property>
</configuration>
and I want to add a node, under the parent, so I'll end up having:
<configuration>
<property>
<name>foo1</name>
<value>bar</value>
</property>
<property>
<name>foo1</name>
<value>baz</value>
</property>
</configuration>
Is that possible with this library? and if so, any pointers/examples would be greatly appreciated.
Add a validxhtml element to the website element. Note that ensure is present by default, and value
defaults to null for elements. The result is something like ...xml: file=/foo/bar.xml xpath=/business/website/validxhtml
The example in the readme does not seem to work. The module fails without output. I've looked through the test cases and haven't found this case. I don't believe the autovivification behaivor is working as intended.
I had to hack in RHEL5/Python 2.4 support, so it is possible that is an issue. There is a branch that shows the fix for that.
- xml: file=./1.xml xpath=/testing/@location
results in:
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
XML Module should become part of Ansible core as that's really something belonging to core. Lets use this ticket to track the progress on getting it part of Ansible core.
in library/xml line 337:
xml_file = os.path.expanduser(module.params['file'])
This fails when 'xmlstring' is used for input and no 'file' is specified.
See ansible/ansible-modules-core#4122 (comment)
From my understanding the project needs permission from original maintainers ( @tbielawa & @github_rhinception ) to change the license.
@tbielawa do you grant permission or know how I can ping to get permission?
The module works great on our xml file.
Could we use this module to get some values from the xml and use them in playbooks?
Thank you!
I'' getting errors like:
With ansible 2.1
al: [desa-wl12c-1.edisa.com]: FAILED! => {"changed": false, "failed": true, "module_stderFile "/tmp/ansible_wnslMv/ansible_module_xml.py", line 424, in \r\n main()\r\n main\r\n get_element_text(x, xpath, namespaces, module)\r\n File "/tmp/ansible_wnslMv/at is_node(tree, xpath, namespaces):\r\n File "/tmp/ansible_wnslMv/ansible_module_xml.py",ces):\r\n File "/tmp/ansible_wnslMv/ansible_module_xml.py", line 154, in xpath_matches\r.etree.pyx", line 2091, in lxml.etree._ElementTree.xpath (src/lxml/lxml.etree.c:53358)\r\n r.init (src/lxml/lxml.etree.c:133440)\r\n File "xpath.pxi", line 276, in lxml.etree.XFile "xpath.pxi", line 148, in lxml.etree._XPathEvaluatorBase.init (src/lxml/lxml.etreContext.init (src/lxml/lxml.etree.c:130211)\r\n File "extensions.pxi", line 82, in lxalueError: need more than 1 value to unpack\r\n", "msg": "MODULE FAILURE", "parsed": false}
Split from #27.
I am attempting to register some facts from a SyncThing configuration XML file.
- name: Config | Gather Facts
xml:
file: '{{st_config}}'
xpath: /configuration
register: st_xml
Will crash the playbook with:
TASK: [syncthing | Config | Gather Facts] *************************************
failed: [default] => {"failed": true, "parsed": false}
BECOME-SUCCESS-rvsyqlylbzmidtcwhhbagfiwfcgbtqgr
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/aburns/.ssh/config
debug1: /Users/aburns/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 54: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 2
Shared connection to 192.168.55.166 closed.
FATAL: all hosts have already failed -- aborting
Interestingly enough, if I add a count: true
statement then it will not crash; however I am not looking for aggregate data.
Ubuntu 14.04 LTS (fresh vagrant image)
python-lxml 3.3.3-1
python 2.7.6
Hi,
When using the text content parameter is it possible to just return the text rather than the element, text pair?
I'm using the following Ansible task in an attempt to retrieve a value from a remote-side XML file:
- name: try to get existing XML value
xml: >
file=/home/XXX/settings.xml
xpath='/settings/setting[@id="setting.setting_key"]/@value'
print_match=true
register: existing_xml_value
The task fails with this output:
TASK: [playbook | try to get existing XML value] ************************
failed: [XXX] => {"failed": true, "parsed": false}
BECOME-SUCCESS-XXX
Traceback (most recent call last):
File "/home/XXX/.ansible/tmp/ansible-tmp-XXX/xml", line 1937, in <module>
main()
File "/home/XXX/.ansible/tmp/ansible-tmp-XXX/xml", line 290, in main
print_match(x, xpath, module)
File "/home/XXX/.ansible/tmp/ansible-tmp-XXX/xml", line 100, in print_match
match_xpaths.append(tree.getpath(m))
TypeError: Argument 'element' has incorrect type (expected lxml.etree._Element, got _ElementStringResult)
OpenSSH_XXX, OpenSSL XXX XXX
debug1: Reading configuration data /home/XXX/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 2
Shared connection to XXX closed.
I may be doing it wrong as there's no explicit documentation at this time for retrieving actual values (as opposed to counts). Is this operation supported?
I would guess that the OpenSSH output in the module error output is a module bug, since no other module I've worked with has such output when it fails.
Please enable OS X tests on travis because it seems kinda impossible to make the xml module to work on it, even when this module is installed and I am running the task against localhost.
Have a look here on how to enable it, is two lines of code https://github.com/pycontribs/tendo/blob/master/.travis.yml
I have the following XML Document from which I am trying to replace the user-name and password elements of a specific section. This is my source XML File
<?xml version="1.0" ?>
<server xmlns="urn:jboss:domain:4.0">
<extensions>
<extension module="org.jboss.as.clustering.infinispan"/>
<extension module="org.jboss.as.connector"/>
<extension module="org.jboss.as.deployment-scanner"/>
<extension module="org.jboss.as.ee"/>
<extension module="org.jboss.as.ejb3"/>
<extension module="org.jboss.as.jaxrs"/>
<extension module="org.jboss.as.jdr"/>
<extension module="org.jboss.as.jmx"/>
<extension module="org.jboss.as.jpa"/>
<extension module="org.jboss.as.jsf"/>
<extension module="org.jboss.as.jsr77"/>
<extension module="org.jboss.as.logging"/>
<extension module="org.jboss.as.mail"/>
<extension module="org.jboss.as.naming"/>
<extension module="org.jboss.as.pojo"/>
<extension module="org.jboss.as.remoting"/>
<extension module="org.jboss.as.sar"/>
<extension module="org.jboss.as.security"/>
<extension module="org.jboss.as.transactions"/>
<extension module="org.jboss.as.webservices"/>
<extension module="org.jboss.as.weld"/>
<extension module="org.wildfly.extension.batch.jberet"/>
<extension module="org.wildfly.extension.bean-validation"/>
<extension module="org.wildfly.extension.io"/>
<extension module="org.wildfly.extension.messaging-activemq"/>
<extension module="org.wildfly.extension.request-controller"/>
<extension module="org.wildfly.extension.security.manager"/>
<extension module="org.wildfly.extension.undertow"/>
<extension module="org.wildfly.iiop-openjdk"/>
</extensions>
<management>
<security-realms>
<security-realm name="ManagementRealm">
<authentication>
<local default-user="$local" skip-group-loading="true"/>
<properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization map-groups-to-roles="false">
<properties path="mgmt-groups.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
<security-realm name="ApplicationRealm">
<authentication>
<local default-user="$local" allowed-users="*" skip-group-loading="true"/>
<properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization>
<properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
</security-realms>
<audit-log>
<formatters>
<json-formatter name="json-formatter"/>
</formatters>
<handlers>
<file-handler name="file" formatter="json-formatter" path="audit-log.log" relative-to="jboss.server.data.dir"/>
</handlers>
<logger log-boot="true" log-read-only="false" enabled="false">
<handlers>
<handler name="file"/>
</handlers>
</logger>
</audit-log>
<management-interfaces>
<http-interface security-realm="ManagementRealm" http-upgrade-enabled="true">
<socket-binding http="management-http"/>
</http-interface>
</management-interfaces>
<access-control provider="simple">
<role-mapping>
<role name="SuperUser">
<include>
<user name="$local"/>
</include>
</role>
</role-mapping>
</access-control>
</management>
<profile>
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.jboss.as.config">
<level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>
<subsystem xmlns="urn:jboss:domain:batch-jberet:1.0">
<default-job-repository name="in-memory"/>
<default-thread-pool name="batch"/>
<job-repository name="in-memory">
<in-memory/>
</job-repository>
<thread-pool name="batch">
<max-threads count="10"/>
<keepalive-time time="30" unit="seconds"/>
</thread-pool>
</subsystem>
<subsystem xmlns="urn:jboss:domain:bean-validation:1.0"/>
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jndi-name="java:jboss/datasources/DEV_BON_MYSQLDS" pool-name="DEV_BON_MYSQLDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/dev_bon_db</connection-url>
<driver>com.mysql</driver>
<security>
<user-name>bon</user-name>
<password>bon</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="com.mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:ee:4.0">
<spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>
<concurrent>
<context-services>
<context-service name="default" jndi-name="java:jboss/ee/concurrency/context/default" use-transaction-setup-provider="true"/>
</context-services>
<managed-thread-factories>
<managed-thread-factory name="default" jndi-name="java:jboss/ee/concurrency/factory/default" context-service="default"/>
</managed-thread-factories>
<managed-executor-services>
<managed-executor-service name="default" jndi-name="java:jboss/ee/concurrency/executor/default" context-service="default" hung-task-threshold="60000" keepalive-time="5000"/>
</managed-executor-services>
<managed-scheduled-executor-services>
<managed-scheduled-executor-service name="default" jndi-name="java:jboss/ee/concurrency/scheduler/default" context-service="default" hung-task-threshold="60000" keepalive-time="3000"/>
</managed-scheduled-executor-services>
</concurrent>
<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/ExampleDS" jms-connection-factory="java:jboss/DefaultJMSConnectionFactory" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:ejb3:4.0">
<session-bean>
<stateless>
<bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
</stateless>
<stateful default-access-timeout="5000" cache-ref="simple" passivation-disabled-cache-ref="simple"/>
<singleton default-access-timeout="5000"/>
</session-bean>
<mdb>
<resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:activemq-ra.rar}"/>
<bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
</mdb>
<pools>
<bean-instance-pools>
<!-- Automatically configure pools. Alternatively, max-pool-size can be set to a specific value -->
<strict-max-pool name="slsb-strict-max-pool" derive-size="from-worker-pools" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
<strict-max-pool name="mdb-strict-max-pool" derive-size="from-cpu-count" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
</bean-instance-pools>
</pools>
<caches>
<cache name="simple"/>
<cache name="distributable" passivation-store-ref="infinispan" aliases="passivating clustered"/>
</caches>
<passivation-stores>
<passivation-store name="infinispan" cache-container="ejb" max-size="10000"/>
</passivation-stores>
<async thread-pool-name="default"/>
<timer-service thread-pool-name="default" default-data-store="default-file-store">
<data-stores>
<file-data-store name="default-file-store" path="timer-service-data" relative-to="jboss.server.data.dir"/>
</data-stores>
</timer-service>
<remote connector-ref="http-remoting-connector" thread-pool-name="default"/>
<thread-pools>
<thread-pool name="default">
<max-threads count="10"/>
<keepalive-time time="100" unit="milliseconds"/>
</thread-pool>
</thread-pools>
<iiop enable-by-default="false" use-qualified-name="false"/>
<default-security-domain value="other"/>
<default-missing-method-permissions-deny-access value="true"/>
<log-system-exceptions value="true"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:io:1.1">
<worker name="default"/>
<buffer-pool name="default"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:infinispan:4.0">
<cache-container name="server" default-cache="default" module="org.wildfly.clustering.server">
<local-cache name="default">
<transaction mode="BATCH"/>
</local-cache>
</cache-container>
<cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
<local-cache name="passivation">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="BATCH"/>
<file-store passivation="true" purge="false"/>
</local-cache>
<local-cache name="persistent">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="BATCH"/>
<file-store passivation="false" purge="false"/>
</local-cache>
</cache-container>
<cache-container name="ejb" aliases="sfsb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan">
<local-cache name="passivation">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="BATCH"/>
<file-store passivation="true" purge="false"/>
</local-cache>
<local-cache name="persistent">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="BATCH"/>
<file-store passivation="false" purge="false"/>
</local-cache>
</cache-container>
<cache-container name="hibernate" default-cache="local-query" module="org.hibernate.infinispan">
<local-cache name="entity">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="local-query">
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="timestamps"/>
</cache-container>
</subsystem>
<subsystem xmlns="urn:jboss:domain:iiop-openjdk:1.0">
<orb socket-binding="iiop" ssl-socket-binding="iiop-ssl"/>
<initializers transactions="spec" security="identity"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
<subsystem xmlns="urn:jboss:domain:jca:4.0">
<archive-validation enabled="true" fail-on-error="true" fail-on-warn="false"/>
<bean-validation enabled="true"/>
<default-workmanager>
<short-running-threads>
<core-threads count="50"/>
<queue-length count="50"/>
<max-threads count="50"/>
<keepalive-time time="10" unit="seconds"/>
</short-running-threads>
<long-running-threads>
<core-threads count="50"/>
<queue-length count="50"/>
<max-threads count="50"/>
<keepalive-time time="10" unit="seconds"/>
</long-running-threads>
</default-workmanager>
<cached-connection-manager/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jdr:1.0"/>
<subsystem xmlns="urn:jboss:domain:jmx:1.3">
<expose-resolved-model/>
<expose-expression-model/>
<remoting-connector/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jpa:1.1">
<jpa default-datasource="" default-extended-persistence-inheritance="DEEP"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jsf:1.0"/>
<subsystem xmlns="urn:jboss:domain:jsr77:1.0"/>
<subsystem xmlns="urn:jboss:domain:mail:2.0">
<mail-session name="default" jndi-name="java:jboss/mail/Default">
<smtp-server outbound-socket-binding-ref="mail-smtp"/>
</mail-session>
</subsystem>
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
<security-setting name="#">
<role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
</security-setting>
<address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/>
<http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
<http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
<http-acceptor name="http-acceptor" http-listener="default"/>
<http-acceptor name="http-acceptor-throughput" http-listener="default">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0"/>
<jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
<jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
<connection-factory name="InVmConnectionFactory" connectors="in-vm" entries="java:/ConnectionFactory"/>
<connection-factory name="RemoteConnectionFactory" connectors="http-connector" entries="java:jboss/exported/jms/RemoteConnectionFactory"/>
<pooled-connection-factory name="activemq-ra" transaction="xa" connectors="in-vm" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory"/>
</server>
</subsystem>
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<remote-naming/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:pojo:1.0"/>
<subsystem xmlns="urn:jboss:domain:remoting:3.0">
<endpoint/>
<http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:resource-adapters:4.0"/>
<subsystem xmlns="urn:jboss:domain:request-controller:1.0"/>
<subsystem xmlns="urn:jboss:domain:sar:1.0"/>
<subsystem xmlns="urn:jboss:domain:security-manager:1.0">
<deployment-permissions>
<maximum-set>
<permission class="java.security.AllPermission"/>
</maximum-set>
</deployment-permissions>
</subsystem>
<subsystem xmlns="urn:jboss:domain:security:1.2">
<security-domains>
<security-domain name="other" cache-type="default">
<authentication>
<login-module code="Remoting" flag="optional">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
<login-module code="RealmDirect" flag="required">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
</authentication>
</security-domain>
<security-domain name="jboss-web-policy" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
<security-domain name="jboss-ejb-policy" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
<security-domain name="jaspitest" cache-type="default">
<authentication-jaspi>
<login-module-stack name="dummy">
<login-module code="Dummy" flag="optional"/>
</login-module-stack>
<auth-module code="Dummy"/>
</authentication-jaspi>
</security-domain>
</security-domains>
</subsystem>
<subsystem xmlns="urn:jboss:domain:transactions:3.0">
<core-environment>
<process-id>
<uuid/>
</process-id>
</core-environment>
<recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:undertow:3.0">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/10"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
<subsystem xmlns="urn:jboss:domain:webservices:2.0">
<wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>
<endpoint-config name="Standard-Endpoint-Config"/>
<endpoint-config name="Recording-Endpoint-Config">
<pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">
<handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
</pre-handler-chain>
</endpoint-config>
<client-config name="Standard-Client-Config"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:weld:3.0"/>
</profile>
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>
</interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
<socket-binding name="http" port="${jboss.http.port:8080}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
<socket-binding name="iiop" interface="unsecure" port="3528"/>
<socket-binding name="iiop-ssl" interface="unsecure" port="3529"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
</socket-binding-group>
</server>
and this is my task configuration within ansible
in vars I defined:
wildfly_namespaces:
- top: "urn:jboss:domain:4.0"
- db: "urn:jboss:domain:datasources:4.0"
and the task is configured like:
- name: Set username
xml:
file={{ wildfly_dir }}/standalone/configuration/{{ sendbon_dev_standalone_xml }}
xpath=//top:server/profile/db:subsystem/datasources/datasource/security/user-name
value={{ mysql_users[0].name }}
namespaces={{ wildfly_namespaces }}
But when I try to run the task I get:
TASK [Set username] ************************************************************
task path: /Users/buddy/dev/ansible/djangi-ansible-playbook/playbook.yml:72
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: vagrant
<127.0.0.1> SSH: EXEC ssh -C -q -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/Users/buddy/dev/ansible/djangi-ansible-playbook/.vagrant/machines/default/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=30 -o ControlPath=/Users/buddy/.ansible/cp/%h-%r -tt 127.0.0.1 '/bin/sh -c '"'"'( umask 22 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1460286620.97-66304934768571 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1460286620.97-66304934768571 `" )'"'"''
<127.0.0.1> PUT /var/folders/hm/2cvlc7l5247fjrfg3xryt3lc0000gn/T/tmpdjUjU1 TO /home/vagrant/.ansible/tmp/ansible-tmp-1460286620.97-66304934768571/xml
<127.0.0.1> SSH: EXEC sftp -b - -C -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/Users/buddy/dev/ansible/djangi-ansible-playbook/.vagrant/machines/default/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=30 -o ControlPath=/Users/buddy/.ansible/cp/%h-%r '[127.0.0.1]'
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: vagrant
<127.0.0.1> SSH: EXEC ssh -C -q -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/Users/buddy/dev/ansible/djangi-ansible-playbook/.vagrant/machines/default/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=30 -o ControlPath=/Users/buddy/.ansible/cp/%h-%r -tt 127.0.0.1 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-sujuxvrrxozvwdccdgtojzuabswznhjv; /bin/sh -c '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1460286620.97-66304934768571/xml; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1460286620.97-66304934768571/" > /dev/null 2>&1'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"''"'"'"'"'"'"'"'"''"'"''
fatal: [default]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "xml"}, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n File \"/home/vagrant/.ansible/tmp/ansible-tmp-1460286620.97-66304934768571/xml\", line 2369, in <module>\r\n main()\r\n File \"/home/vagrant/.ansible/tmp/ansible-tmp-1460286620.97-66304934768571/xml\", line 407, in main\r\n set_target(x, xpath, namespaces, attribute, value, module)\r\n File \"/home/vagrant/.ansible/tmp/ansible-tmp-1460286620.97-66304934768571/xml\", line 224, in set_target\r\n if not is_node(tree, xpath, namespaces):\r\n File \"/home/vagrant/.ansible/tmp/ansible-tmp-1460286620.97-66304934768571/xml\", line 135, in is_node\r\n if xpath_matches(tree, xpath, namespaces):\r\n File \"/home/vagrant/.ansible/tmp/ansible-tmp-1460286620.97-66304934768571/xml\", line 155, in xpath_matches\r\n if tree.xpath(xpath, namespaces=namespaces):\r\n File \"lxml.etree.pyx\", line 2091, in lxml.etree._ElementTree.xpath (src/lxml/lxml.etree.c:53358)\r\n File \"xpath.pxi\", line 342, in lxml.etree.XPathDocumentEvaluator.__init__ (src/lxml/lxml.etree.c:133440)\r\n File \"xpath.pxi\", line 276, in lxml.etree.XPathElementEvaluator.__init__ (src/lxml/lxml.etree.c:132591)\r\n File \"xpath.pxi\", line 148, in lxml.etree._XPathEvaluatorBase.__init__ (src/lxml/lxml.etree.c:131208)\r\n File \"xpath.pxi\", line 57, in lxml.etree._XPathContext.__init__ (src/lxml/lxml.etree.c:130211)\r\n File \"extensions.pxi\", line 82, in lxml.etree._BaseContext.__init__ (src/lxml/lxml.etree.c:121254)\r\nValueError: need more than 1 value to unpack\r\n", "msg": "MODULE FAILURE", "parsed": false}
NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit @playbook.retry
PLAY RECAP *********************************************************************
default : ok=62 changed=3 unreachable=0 failed=1
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
which seems like an odd error to me
It would be great to add a section to the README.md on how to install this module. This may be obvious to experienced users of Ansible but not so much for more casual or new users...
Hi
I'm stuck on a little problem and don't see this in the readme documentation.
I want to change all attributes of a certain list of tags, example:
<serverSettings>
<socketAddresses>
<socket address="10.69.14.84" port="9933" type="TCP"/>
<socket address="10.69.14.84" port="9933" type="UDP"/>
</socketAddresses>
</serverSettings>
So in this example, I want to change the address attributes of the socket tags.
I had following yaml code, but it doesn't seem to work:
- name: Setting ip address for all smartfox servers.
xml:
file:"{{item.xml_file}}"
xpath:/serverSettings/socketAddresses/socket/*
attribute: address
value: "{{ip_address}}"
with_items:
- xml_file: "{{servers[0]}}/config/server.xml"
- xml_file: "{{servers[1]}}/config/server.xml"
Can someone help me with this?
Thanks in advance!
Give this Ansible task:
- name: ensure required setting
xml: >
file=.../settings.xml
xpath='/settings/setting[@id="setting.key"]/@value'
value=true
and this remote XML file:
<settings>
<setting id="setting.key" value="false" />
</settings>
I get this error:
TASK: [playbook | ensure required setting] *******************
failed: [XXX] => {"failed": true}
msg: Xpath /settings/setting[@id="setting.key"]/@value does not reference a node!
The documentation (through showing how to remove an attribute) suggests that I should be able to alter an attribute's value. Am I doing something wrong?
The documentation should include a code sample that loads an attribute value into an ansible variable. I may make sense to provide a simple example for reading the charset
attribute from insite HTML page. html>headers>meta>charset
. Maybe even specifying what happens if it is missing.
I've been trying to edit xfce4-keyboard-shortcuts.xml to add some shortcut keys, but I've translated my question/problem back to the 'ansible-xml-beers.xml' examples you have provided with ansible-xml to ease the discussion.
original ansible-xml-beers.xml:
<?xml version='1.0' encoding='UTF-8'?>
<business type="bar">
<name>Tasty Beverage Co.</name>
<beers>
<beer>Rochefort 10</beer>
<beer>St. Bernardus Abbot 12</beer>
<beer>Schlitz</beer>
</beers>
<rating subjective="true">10</rating>
<website>
<mobilefriendly/>
<address>http://tastybeverageco.com</address>
</website>
I want to add a beer next to the existing beer elements in the node, e.g.: <beer>Heineken</beer>
, but only if it is not already present.
I've tried "test-add-children-elements.yml", but this will add this beer-element every time the Ansible Playbook runs.
After running "test-set-children-elements.yml", as expected, only the beer element I've selected is in the node while all other previously present beer elements in the xml file are removed.
Is there a (single) function similar to "test-add-children-elements.yml", which will ensure that the specified child element will be present (with specified attributes), add it if it does not exist but leave the other existing elements in place? Additionally, doing this in such a way if an element like <beer type="Dutch">Heineken</beer>
exists and I want to change it to <beer type="European">Heineken</beer>
, no duplicates will be created?
should be
abort("Xpath " + xpath + " does not reference a node!", module)
This is my task:
- name: Remove default H2 configuration (1/2)
xml: xpath=/server/profile/subsystem/datasources/datasource[@pool-name=ExampleDS] file=/opt/apps/jboss/standalone/configuration/standalone.xml ensure=absent
This is what ansible executes on the target:
ansible-xml: Invoked with xpath= count=None set_children=None namespaces={} attribute=None pretty_print=False add_children=None value=None ensure=absent file=/opt/apps/jboss/standalone/configuration/standalone.xml print_match=None xmlstring=None
Note that xpath
is missing so the call is pretty useless.
When running a task to add a child element, the child element is added on each execution.
- name: Add child element
xml:
file: "/tmp/ansible-xml-beers.xml"
xpath: /business/beers
add_children:
- beer: "Old Rasputin"
<?xml version='1.0' encoding='UTF-8'?>
<business type="bar">
<name>Tasty Beverage Co.</name>
<beers>
<beer>Rochefort 10</beer>
<beer>St. Bernardus Abbot 12</beer>
<beer>Schlitz</beer>
<beer>Old Rasputin</beer>
<beer>Old Rasputin</beer><beer>Old Rasputin</beer><beer>Old Rasputin</beer><beer
>Old Rasputin</beer></beers>
<rating subjective="true">10</rating>
<website>
<mobilefriendly/>
<address>http://tastybeverageco.com</address>
</website>
</business>
Given XML in file.xml
:
<a>
<b>
<c>D</c>
</b>
</a>
the following Ansible task:
- name: ensure D
xml: file=file.xml xpath=/a/b/c value=D
notify: restart the thing
always returns as changed
, even when no change was made, resulting in handlers being triggered when not necessary.
I need to get id
for username
=jenkinsand privateKeySource
=class="com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$UsersPrivateKeySource" and from an XML file. Can I do that using your module? How?
<?xml version='1.0' encoding='UTF-8'?>
<com.cloudbees.plugins.credentials.SystemCredentialsProvider plugin="[email protected]">
<domainCredentialsMap class="hudson.util.CopyOnWriteMap$Hash">
<entry>
<com.cloudbees.plugins.credentials.domains.Domain>
<specifications/>
</com.cloudbees.plugins.credentials.domains.Domain>
<java.util.concurrent.CopyOnWriteArrayList>
<com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey plugin="[email protected]">
<scope>GLOBAL</scope>
<id>cb775b84-d310-4afa-8a0c-f228a91bb2c3</id>
<description></description>
<username>jenkins</username>
<passphrase>pJfDVym6JTlclQVHhVqMvA==</passphrase>
<privateKeySource class="com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$UsersPrivateKeySource"/>
</com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey>
<com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
<scope>GLOBAL</scope>
<id>b1c0059a-5496-4b36-a1d2-25b8f96bdbaf</id>
<description>yo</description>
<username>jenkins</username>
<password>YuI6K23ePqB56ZgPO0k0S5m9nY/82k7Fh/xx619OOtk=</password>
</com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
</java.util.concurrent.CopyOnWriteArrayList>
</entry>
</domainCredentialsMap>
</com.cloudbees.plugins.credentials.SystemCredentialsProvider>
This might be the same issue as #53 and maybe #7.
The XML:
<?xml version='1.0' encoding='UTF-8'?>
<localconfig>
<key name="smtp_notify">
<value>yes</value>
</key>
</localconfig>
This task works to set the value above:
- name: Set localconfig options
xml:
file: "/opt/zimbra/conf/localconfig.xml"
xpath: "/localconfig/key[@name='smtp_notify']/value"
value: "yes"
But this fails:
- name: Set localconfig options
xml:
file: "/opt/zimbra/conf/localconfig.xml"
xpath: "/localconfig/key[@name='smtp_notify']/value"
value: ""
Expected result:
<?xml version='1.0' encoding='UTF-8'?>
<localconfig>
<key name="smtp_notify">
<value></value>
</key>
</localconfig>
Actual result:
TASK [Set localconfig options] *************************************************
fatal: [zmdir2.example.com]: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
This is version 0.3.1 if I'm not mistaken (whatever was current on galaxy today).
It would be very useful to be able to add a child comment to xml or to be able to comment a full element as xml :
For example adding
<!--URL Pattern to skip the XSS prevention-->
or commenting an existing child :
<Pattern>wso2</Pattern>
becomes
<!--Pattern>wso2</Pattern-->
Line 132 of the Readme says that the you can set a node's value and parent nodes will be implicitly created. This makes a lot of sense and avoids a mass of conditional checks to ensure parent nodes exist (and adding them if they don't). However it looks like this functionality is broken.
Given the file:
<user>
<properties>
<something/>
</properties>
</user>
and the following ansible task:
- xml:
file: "config.xml"
xpath: "/user/properties/several/deep"
value: "doink"
the following xml should result:
<user>
<properties>
<something/>
<several>
<deep>doink</deep>
</several>
</properties>
</user>
However, instead, the following error is output:
FAILED! => {"changed": false, "failed": true, "msg": "Xpath /user/properties/several/deep does not reference a node!"}
The same applies to attributes on non-existent nodes.
Ping to relevant contributors:
Thanks to everyone for showing their interest in this module! The response we've gotten since we first published the (very rough and very incomplete) first version has been more than I ever anticipated.
Sadly, the original maintainers no longer have the time required to give this project the attention it now requires. The time has come for this module to find new care takers who can give it the care it requires. Therefore @RHInception has decided that we are officially end-of-life'ing this project.
From reviewing the most recent comments on the issue tracker, it seems that @Lx and @cmprescott have expressed the most interest in taking over this project. I do not want to personally dictate the future of this module, rather I'd like to create a proper venue (this issue) for arranging a clean hand-over of the project.
All PR's which were open this morning have been merged, de-conflicted, and pushed.
After merging all open PR's I manually closed issue #13 (tilde-expansion in file paths)
The remaining open issues will not be addressed by myself or the rest of the RH Inception team and are left as an exercise to the new future maintainers
I'd love to see a contributor step up and state their intention to officially take over ownership of the project. We want to leave the future of this module in the hands of those who still have the energy required to do the needful.
Once consensus has been reached I'll be happy to arrange to transfer ownership of the project to the new maintainer(s). We will not interfere if a consensus cannot be reached, rather the project will go into read-only mode and refer new users to the forks chart.
Any takers? (thoughts?)
On my local machine i get this:
TASK [Test expected result] ****************************************************
task path: /tmp/ansible-xml-0.3.4/tests/test-add-children-with-attributes.yml:14
fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["diff", "results/test-add-children-with-attributes.xml", "/tmp/ansible-xml-beers.xml"], "delta": "0:00:00.001703", "end": "2016-09-15 10:41:08.081700", "failed": true, "rc": 1, "start": "2016-09-15 10:41:08.079997", "stderr": "", "stdout": "8c8\n< <beer name=\"Ansible Brew\" type=\"light\"/></beers>\n---\n> <beer type=\"light\" name=\"Ansible Brew\"/></beers>", "stdout_lines": ["8c8", "< <beer name=\"Ansible Brew\" type=\"light\"/></beers>", "---", "> <beer type=\"light\" name=\"Ansible Brew\"/></beers>"], "warnings": []}
When i manually do the diff is see this:
$ diff results/test-add-children-with-attributes.xml /tmp/ansible-xml-beers.xml
8c8
< <beer name="Ansible Brew" type="light"/></beers>
---
> <beer type="light" name="Ansible Brew"/></beers>
On the other hand the TravisCI badge says, that the build passes. The test fails with the tests in release download 0.3.4
and b9ec075 (current master).
Ansible version: ansible 2.1.1.0
Using python: 2.7.11
Since i come from chef env to ansible i have hard time to figure out the extras module.
I need the xml module but how i i install/use it?
I have downloaded it and extract it to the ansible machine that runs ver 1.9.6.
Now?
Following the the README.md example:
Add a phonenumber element to the business element Implicit mkdir -p behavior where applicable (parent xml nodes created automatically)
xml: file=/foo/bar.xml xpath=/business/phonenumber value=555-555-1234
My ansible task:
xml:
file: /var/lib/jenkins/config.xml
xpath: /hudson/securityRealm/serviceName
value: sshd
Target XML:
<?xml version='1.0' encoding='UTF-8'?>
<hudson>
<disabledAdministrativeMonitors/>
<version>1.0</version>
<numExecutors>2</numExecutors>
<mode>NORMAL</mode>
<useSecurity>true</useSecurity>
<authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
<securityRealm class="hudson.security.PAMSecurityReal" plugin="[email protected]">
</securityRealm>
<disableRememberMe>false</disableRememberMe>
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
<workspaceDir>${JENKINS_HOME}/workspace/${ITEM_FULLNAME}</workspaceDir>
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
<markupFormatter class="hudson.markup.EscapedMarkupFormatter"/>
<jdks/>
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
<clouds/>
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
<views>
<hudson.model.AllView>
<owner class="hudson" reference="../../.."/>
<name>All</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>
</views>
<primaryView>All</primaryView>
<slaveAgentPort>0</slaveAgentPort>
<label/>
<nodeProperties/>
<globalNodeProperties/>
</hudson>
Expected modified XML:
<?xml version='1.0' encoding='UTF-8'?>
<hudson>
<disabledAdministrativeMonitors/>
<version>1.0</version>
<numExecutors>2</numExecutors>
<mode>NORMAL</mode>
<useSecurity>true</useSecurity>
<authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
<securityRealm class="hudson.security.PAMSecurityReal" plugin="[email protected]">
<serviceName>sshd</serviceName>
</securityRealm>
<disableRememberMe>false</disableRememberMe>
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
<workspaceDir>${JENKINS_HOME}/workspace/${ITEM_FULLNAME}</workspaceDir>
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
<markupFormatter class="hudson.markup.EscapedMarkupFormatter"/>
<jdks/>
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
<clouds/>
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
<views>
<hudson.model.AllView>
<owner class="hudson" reference="../../.."/>
<name>All</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>
</views>
<primaryView>All</primaryView>
<slaveAgentPort>0</slaveAgentPort>
<label/>
<nodeProperties/>
<globalNodeProperties/>
</hudson>
Actual results:
fatal: [10.0.0.20]: FAILED! => {"changed": false, "failed": true, "msg": "Xpath /hudson/securityRealm/serviceName does not reference a node!"}
config.xml
<?xml version='1.0' encoding='UTF-8'?>
<hudson></hudson>
Task
xml:
file="/var/lib/jenkins/config.xml"
xpath="/hudson/blaaa"
value="pete"
Error:
msg: Xpath /hudson/blaaa does not reference a node!
I would expect a new Node <blaaa>pete</blaaa>
would be generated.
Hi everyone,
I am newbie in ansible programing. I would like to know there are any way to use xpath axes with ansible-xml.
About XPath Axes http://www.w3schools.com/xsl/xpath_axes.asp
XML
<configuration changed-seconds="1470644856" changed-localtime="2016-08-08 15:27:36 ICT">
<access>
<address-assignment>
<pool>
<name>IP-POOL</name>
<family>
<inet>
<network>192.168.1.0/24</network>
<range>
<name>1</name>
<low>192.168.1.0</low>
<high>192.168.1.255</high>
</range>
</inet>
</family>
</pool>
</address-assignment>
</access>
</configuration>
TASK
- name: Get exact poolname from prefix
xml:
file: "{{ inventory_hostname }}-show-acces-pool.xml"
xpath: '//pool/family/inet[network="192.168.1.0/24"]/preceding-sibling::name[2]'
content: 'text'
register: exact_poolname
EXPECT RESULT
exact_poolname = IP-POOL
Hello,
In order to patch WSO2, I need to add a child to an element that has no namespace but whose parent has a namespace. The following code works perfectly with a standard xml (example file from ansible-xml) and creates a leaf testtest
with content blabla
:
- name: Creation XSSPreventionConfig
become: yes
become_user: root
xml:
file: /tmp/ansible-xml-beers.xml
xpath: /business/beers
add_children:
- XSSPreventionConfig:
when: true
- name: test xml
become: yes
become_user: root
xml:
file: /tmp/ansible-xml-beers.xml
xpath: /business/beers/XSSPreventionConfig
add_children:
- testtest: "blabla"
when: true
Whilst the following code does not work on the same file (namespace version)
- name: add child poom to beers namesspace
become: yes
become_user: root
xml:
file: /tmp/ansible-xml-namespaced-beers.xml
xpath: /bus:business/ber:beers
namespaces:
bus: http://test.business
ber: http://test.beers
web: http://test.website
add_children:
- poom:
when: true
- name: ajout enfant a poom
become: yes
become_user: root
xml:
file: /tmp/ansible-xml-namespaced-beers.xml
xpath: /bus:business/ber:beers/poom
namespaces:
bus: http://test.business
ber: http://test.beers
web: http://test.website
add_children:
- beer: "bla"
when: true
This last snippet will add a poom
child, but will not add a beer
child to poom
.
By the way, I have the same problem with counting beer child with namespace xml example, but I can do it fine with the basic xml. In the namespace example, I can count the beers
element (returns 1), but I cannot seem to be able to count the beers elements (returns 0).
Seems to say that Xpath does not reference a node.
Doesn't seem to be able to handle the lengthy opening tag.
For example we may want to load the XML form an ansible variable instead of a file, probably after loading it using the uri
module.
So far it seems that's not possible, or if it is it means that's not documented. Trying to workaround this by saving the variable inside a file would require too much work which will produce too hard to maintain playbooks.
See
ansible/ansible-modules-core#4122 (diff)
ansible/ansible-modules-core#4122 (comment)
ansible/ansible-modules-core#4122 (comment)
ansible/ansible-modules-core#4122 (diff)
ansible/ansible-modules-core#4122 (comment)
ansible/ansible-modules-core#4122 (comment)
ansible/ansible-modules-core#4122 (comment)
ansible/ansible-modules-core#4122 (diff)
ansible/ansible-modules-core#4122 (comment)
ansible/ansible-modules-core#4122 (diff)
ansible/ansible-modules-core#4122 (comment)
ansible/ansible-modules-core#4122 (diff)
ansible/ansible-modules-core#4122 (comment)
ansible/ansible-modules-core#4122 (diff)
ansible/ansible-modules-core#4122 (comment)
ansible/ansible-modules-core#4122 (diff)
ansible/ansible-modules-core#4122 (comment)
Hej hej, have you thought about incorporating the module with Ansible upstream? It would be a great place to bring it more attention and to improve it further on.
Hi all,
I was trying to use like :
../role/artifactory/defaults/main.yml has contain:
artifactory_proxy:
- key: "test-proxy"
- host: "192.168.1.1"
- port: "3128"
- username: ""
- password: ""
- defaultProxy: "false"
and the ../role/artifactory/task/configure.yml
- name: Artifactory config | Add proxy settings to the config
xml:
file: /tmp/artifactory.config.xml
xpath: /config/proxies/proxy
add_children: "{{ artifactory_proxy }}"
The task finished with ok, but there is no change, and if the proxy element is not exist in the xml file it fail with a strange ssh error ...
What I do wrong ?
Thanks!
Hello.
I have tomcat context file which looks like:
<?xml version='1.0' encoding='utf-8'?>
<Context>
<Resource type="javax.sql.DataSource"
name="jdbc/UniDataDataSource"
description="UniData Database"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/unidata"
username="postgres"
password="postgres"
initialSize="10"
maxActive="100"
maxIdle="50"
minIdle="10"
suspectTimeout="60"
timeBetweenEvictionRunsMillis="30000"
minEvictableIdleTimeMillis="60000"
testOnBorrow="true"
validationQuery="SELECT 1"
validationInterval="30000"
removeAbandoned="true"
removeAbandonedTimeout="180"
logAbandoned="true"
abandonWhenPercentageFull="50"
jdbcInterceptors="ResetAbandonedTimer" />
</Context>
I want change their attributes, but do not loose formatting. Is it possible?
My playbook similar to (simplified):
- name: Provide database access to tomcat
xml:
file: context.xml.default
pretty_print: True
xpath: /Context/Resource[@name='{{item.name}}']
attribute: "{{item.attribute}}"
value: "{{item.value}}"
with_items:
- { name: 'jdbc/UniDataDataSource', attribute: url, value: 'test_attribute_value' }
And result in one string:
<?xml version='1.0' encoding='UTF-8'?>
<Context>
<Resource type="javax.sql.DataSource" name="jdbc/UniDataDataSource" description="UniData Database" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" driverClassName="org.postgresql.Driver" url="test_attribute_value" username="postgres" password="postgres" initialSize="10" maxActive="100" maxIdle="50" minIdle="10" suspectTimeout="60" timeBetweenEvictionRunsMillis="30000" minEvictableIdleTimeMillis="60000" testOnBorrow="true" validationQuery="SELECT 1" validationInterval="30000" removeAbandoned="true" removeAbandonedTimeout="180" logAbandoned="true" abandonWhenPercentageFull="50" jdbcInterceptors="ResetAbandonedTimer"/>
</Context>
I understand what it is Resource
tag with many attributes and no child elements. It there any possibility preserve formatting similar to initial state?
Hello,
Dict elements not supported on add_children
With a task like:
Variable:
entornos:
libra:
{ nombre: 'test1' }
pruebas:
{ nombre: 'test2' }
I got message:
fatal: [192.168.231.178]: FAILED! => {"failed": true, "msg": "'item' is undefined"}
Is it possible to create multiple child elements with a dictionary variable?
Thanks in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.