With Junos 15.1 you could do this in a single operation in XML with the following:
<configuration>
<firewall>
<family>
<inet>
<filter>
<name>ham</name>
<term operation="create" insert="before" name="spam">
<name>eggs</name>
<from>
...
</from>
</term>
</filter>
</inet>
</family>
</firewall>
</configuration>
For earlier versions of Junos, then it would require a two step approach with the playbook, e.g. first create the term, and then another to move the term.
---
- hosts: all
connection: local
roles:
- Juniper.junos
tasks:
- name: install_config
ignore_errors: false
junos_install_config:
host: "{{ inventory_hostname }}"
user: "{{user}}"
passwd: "{{passwd}}"
overwrite: "no"
file: "config1.xml"
- name: move_config
ignore_errors: false
junos_install_config:
host: "{{ inventory_hostname }}"
user: "{{user}}"
passwd: "{passwd}}"
overwrite: "no"
file: "config2.xml"
config1.xml
<configuration>
<firewall>
<family>
<inet>
<filter>
<name>ham</name>
<term>
<name>eggs</name>
<from>
...
</from>
</term>
</filter>
</inet>
</family>
</firewall>
</configuration>
config2.xml
<configuration>
<firewall>
<family>
<inet>
<filter>
<name>ham</name>
<term insert="before" name="spam">
<name>eggs</name>
</term>
</filter>
</inet>
</family>
</firewall>
</configuration>
Regards,
Andy