<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: User role elevation with ansible in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/457052#M2870</link>
    <description>&lt;P&gt;That is 100% what I needed! Thank you sooooo much for saving me a TON of time. I would like to know more about the generating and parsing of the XML so if you have any guides or know of any good training on this please let me know.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jan 2022 19:08:53 GMT</pubDate>
    <dc:creator>Matthew_Gee</dc:creator>
    <dc:date>2022-01-05T19:08:53Z</dc:date>
    <item>
      <title>User role elevation with ansible</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/456748#M2866</link>
      <description>&lt;P&gt;I am looking for a playbook to change a users role to a different group and make them a super user on Panorama. Has anyone accomplished this before?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 18:29:09 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/456748#M2866</guid>
      <dc:creator>Matthew_Gee</dc:creator>
      <dc:date>2022-01-04T18:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: User role elevation with ansible</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/456939#M2867</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/200232"&gt;@Matthew_Gee&lt;/a&gt;&amp;nbsp;Hope this helps. The user needs to exist already per your original ask.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;---
#
# Ansible playbook to make an existing administrator in Panorama a superuser
#
# Example usage: ansible-playbook -i inventory make-admin-superuser.yml -e "admin_user=alice"
#


- hosts: '{{ target | default("panorama") }}'
  connection: local

  vars:
    device:
      ip_address: "{{ ip_address }}"
      username: "{{ username | default(omit) }}"
      password: "{{ password | default(omit) }}"
      api_key: "{{ api_key | default(omit) }}"

  tasks:
    - name: Change administrator to superuser
      paloaltonetworks.panos.panos_administrator:
        provider: '{{ device }}'
        admin_username: '{{ admin_user }}'
        superuser: true

    - name: Commit
      paloaltonetworks.panos.panos_commit_panorama:
        provider: "{{ device }}"
      register: results

    - debug:
        msg: "Commit with Job ID: {{ results.jobid }} had output: {{ results.details }}"
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 12:39:36 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/456939#M2867</guid>
      <dc:creator>JimmyHolland</dc:creator>
      <dc:date>2022-01-05T12:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: User role elevation with ansible</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/456954#M2868</link>
      <description>&lt;P&gt;It definitely helps, is there a way to see what custom role and profile the user is before making the change and store it as a variable?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 13:52:59 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/456954#M2868</guid>
      <dc:creator>Matthew_Gee</dc:creator>
      <dc:date>2022-01-05T13:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: User role elevation with ansible</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/457014#M2869</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/200232"&gt;@Matthew_Gee&lt;/a&gt;&amp;nbsp;You could do something like that with these tasks at the start of the playbook, before changing the administrator to a superuser:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;    - name: Get admin user role details, and register the response
      paloaltonetworks.panos.panos_op:
        provider: "{{ device }}"
        cmd: '&amp;lt;show&amp;gt;&amp;lt;config&amp;gt;&amp;lt;running&amp;gt;&amp;lt;xpath&amp;gt;mgt-config/users/entry[@name="{{ admin_user }}"]/permissions/role-based&amp;lt;/xpath&amp;gt;&amp;lt;/running&amp;gt;&amp;lt;/config&amp;gt;&amp;lt;/show&amp;gt;'
        cmd_is_xml: true
      register: adminresult

    - name: Parse out role from XML response
      community.general.xml:
        xmlstring: "{{ adminresult.stdout_xml }}"
        xpath: /response[@status='success']/result/role-based/custom/profile
        content: text
      register: therole

    - debug:
        msg: "{{ therole.matches[0].profile }}"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 16:27:15 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/457014#M2869</guid>
      <dc:creator>JimmyHolland</dc:creator>
      <dc:date>2022-01-05T16:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: User role elevation with ansible</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/457052#M2870</link>
      <description>&lt;P&gt;That is 100% what I needed! Thank you sooooo much for saving me a TON of time. I would like to know more about the generating and parsing of the XML so if you have any guides or know of any good training on this please let me know.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 19:08:53 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/457052#M2870</guid>
      <dc:creator>Matthew_Gee</dc:creator>
      <dc:date>2022-01-05T19:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: User role elevation with ansible</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/457269#M2872</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/200232"&gt;@Matthew_Gee&lt;/a&gt;&amp;nbsp;For panos_op, I find it is easiest to debug the CLI. Find the CLI command for the thing you're trying to do then "debug cli on" and copy the XML syntax there. The CLI uses the same API which Ansible does (via pan-os-python under the hood). More details on this approach here:&amp;nbsp;&lt;A href="https://docs.paloaltonetworks.com/pan-os/10-1/pan-os-panorama-api/get-started-with-the-pan-os-xml-api/explore-the-api/use-the-cli-to-find-xml-api-syntax.html" target="_blank"&gt;https://docs.paloaltonetworks.com/pan-os/10-1/pan-os-panorama-api/get-started-with-the-pan-os-xml-api/explore-the-api/use-the-cli-to-find-xml-api-syntax.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To parse the XML, check the output from the CLI command you executed and then work out the xpath down the XML which you need for your variable. Then I used the XML module here to parse it:&amp;nbsp;&lt;A href="https://docs.ansible.com/ansible/latest/collections/community/general/xml_module.html" target="_blank"&gt;https://docs.ansible.com/ansible/latest/collections/community/general/xml_module.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 16:36:13 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/user-role-elevation-with-ansible/m-p/457269#M2872</guid>
      <dc:creator>JimmyHolland</dc:creator>
      <dc:date>2022-01-06T16:36:13Z</dc:date>
    </item>
  </channel>
</rss>

