如何获得下面ansible的rolly配置?
遥控器:
[nsaunders@rolly ~]$
[nsaunders@rolly ~]$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 8.2.2004 (Core)
Release: 8.2.2004
Codename: Core
[nsaunders@rolly ~]$
[nsaunders@rolly ~]$ ansible --version
ansible 2.9.13
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/nsaunders/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
[nsaunders@rolly ~]$
[nsaunders@rolly ~]$ show config
bash: show: command not found...
[nsaunders@rolly ~]$
[nsaunders@rolly ~]$ ansible show config
usage: ansible [-h] [--version] [-v] [-b] [--become-method BECOME_METHOD]
[--become-user BECOME_USER] [-K] [-i INVENTORY] [--list-hosts]
[-l SUBSET] [-P POLL_INTERVAL] [-B SECONDS] [-o] [-t TREE] [-k]
[--private-key PRIVATE_KEY_FILE] [-u REMOTE_USER]
[-c CONNECTION] [-T TIMEOUT]
[--ssh-common-args SSH_COMMON_ARGS]
[--sftp-extra-args SFTP_EXTRA_ARGS]
[--scp-extra-args SCP_EXTRA_ARGS]
[--ssh-extra-args SSH_EXTRA_ARGS] [-C] [--syntax-check] [-D]
[-e EXTRA_VARS] [--vault-id VAULT_IDS]
[--ask-vault-pass | --vault-password-file VAULT_PASSWORD_FILES]
[-f FORKS] [-M MODULE_PATH] [--playbook-dir BASEDIR]
[-a MODULE_ARGS] [-m MODULE_NAME]
pattern
ansible: error: unrecognized arguments: config
[nsaunders@rolly ~]$ 当地:
nicholas $
nicholas $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
nicholas $
nicholas $ cat first_playbook.yml
---
- name: Network Getting Started First Playbook
connection: network_cli
gather_facts: false
hosts: all
tasks:
- name: Get config for VyOS devices
vyos_facts:
gather_subset: all
- name: Display the config
debug:
msg: "The hostname is {{ ansible_net_hostname }} and the OS is {{ ansible_net_version }}"
nicholas $
nicholas $ yamllint first_playbook.yml
first_playbook.yml
15:81 error line too long (97 > 80 characters) (line-length)
nicholas $
nicholas $ ansible all -i rolly.foo, -c network_cli -u nsaunders -k -m centos_facts -e ansible_network_os=centos
SSH password:
rolly.foo | FAILED! => {
"msg": "network os centos is not supported"
}
nicholas $ 参考资料:
https://www.ansible.com/blog/getting-started-writing-your-first-playbook
发布于 2020-09-15 13:35:26
此错误是由于ansible_network_os:值无效造成的。
您尝试安装的游戏手册是用于网络设备的。而且,由于centos不是网络设备操作系统,游戏将失败。在这里,您可以找到支持的网络操作系统。Ansible_网络_os值:不可用文件
如果您没有任何设备运行支持的网络操作系统,我建议您遵循常规用户指南。不可靠用户指南
我的建议是建立一个简单的游戏手册,将运行在您的环境。了解以下概念。Control node Managed nodes Inventory Modules Tasks Playbooks
下面是一个简短的例子。这将只执行hostname,确认它在预期主机上执行。假设nicholas是您的控制节点,rolly是托管节点。
在nicholas上:像以前一样用控制节点和托管节点创建一个库存。inventory.txt:
[local]
localhost ansible_connection=local
[managed_node]
rolly ansible_host= ansible_user= ansible_ssh_pass=myplaybook.yml:
---
- name: This will get hostname localy on control node
hosts: localhost
tasks:
- name: get hostname
command: hostname
register: result
- name: print hostname
debug:
var: result
- name: This will get hostname remote on manged node
hosts: rolly
tasks:
- name: get hostname
command: hostname
register: result
- name: print hostname
debug:
var: result然后在控制节点上执行:ansible-playbook -i inventory.txt myplaybook.yml
发布于 2020-09-15 06:58:21
nicholas $
nicholas $ cat ansible.cfg
[defaults]
inventory = hosts
ask_vault_pass = True
[privilege_escalation]
become_ask_pass = True
nicholas $
nicholas $ sudo ansible-playbook first_playbook.yml --connection=local
BECOME password:
Vault password:
[WARNING]: Unable to parse /home/nicholas/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [Network Getting Started First Playbook] **************************************************************************************
skipping: no hosts matched
PLAY RECAP *************************************************************************************************************************
nicholas $ 作为一个远程的变通使用,尽管它显然需要一些额外的配置。
https://devops.stackexchange.com/questions/12409
复制相似问题