Ansible - Jalovec - spustit příkaz konfigurovat

0

Otázka

Musím napsat úkol s cílem spustit na Juniper MX

> configure
# deactivate system scripts
# deactivate event-options
# commit and-quit

Zkoušel jsem (https://ansible-juniper-collection.readthedocs.io/en/latest/config.html):

- config:
    load: 'merge'
    lines:
      - deactivate system scripts
    comment: 'Ansible Upgrade - Deactivate'
    commit: true
  vars:
    ansible_connection: local

ale chápu

Failure loading the configuraton: ConfigLoadError(severity: error, bad_element: deactivate, message: error: syntax error)

Rr

ansible juniper
2021-11-23 16:15:06
1

Nejlepší odpověď

0

Ok hlavním problémem bylo ignorovat prohlášení a konfigurovat exkluzivní

Tři řešení:

Ansible:

- config:
    load: 'merge'
    lines:
      - activate system scripts
    comment: 'Ansible Upgrade - Activate'
    commit: true
    commit_empty_changes: true
    config_mode: exclusive
    ignore_warning: 
      - statement not found
  vars:
    ansible_connection: local

Nebo Pythonu:

from jnpr.junos import Device
from jnpr.junos.utils.config import Config

dev = Device(host="xxx", user="xxx", password="xxx", port=22).open()

# Ignore warning in load !!!
# jnpr.junos.exception.ConfigLoadError: 
# ConfigLoadError(severity: warning, bad_element: None, message: warning: statement not found)
with Config(dev, mode='exclusive') as cu:
    cu.load('deactivate system scripts', merge=True, ignore_warning=['statement not found'])
    cu.pdiff()
    cu.commit(comment='Test Ansible deact')
    
dev.close()

Nebo Pythonu:

from jnpr.junos import Device
from jnpr.junos.utils.start_shell import StartShell

dev = Device(host="xxx", user="xxx", password="xxx", port=22).open()

with StartShell(dev) as ss:
    output = ss.run("""cli -c 'configure; deactivate system scripts; commit comment "Test Ansible"'; """, timeout=30)
    print(output)

dev.close()
2021-11-24 15:19:16

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................