Ansible-Juniper-실행 명령을 구성

0

질문

을 작성하는 데 필요한 작업을 실행하기 위해에 주니퍼 MX

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

I tried(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

그러나 나

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

Rr

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

최고의 응답

0

확인 주요 문제는 무시 문 및 구성 독점

세 솔루션:

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

또는 Python:

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()

또는 Python:

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

다른 언어로

이 페이지는 다른 언어로되어 있습니다

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