ansible

ansible - cisco IOS and “reload” command

浪子不回头ぞ 提交于 2019-12-24 07:35:07
问题 I would like to send command "reload in " to Cisco IOS, but that specific command needs to be confirmed like below: #reload in 30 Reload scheduled in 30 minutes by admin on vty0 (192.168.253.15) Proceed with reload? [confirm] It semms like ios_command module doesn't handle such case. My configuration: tasks: - name: do reload in case of "catting off" ios_command: commands: reload in 30 commands: y provider: "{{ cli }}" And response from playbook: TASK [do reload in case of "catting off"] ****

Ansible querying AWS AMIs

家住魔仙堡 提交于 2019-12-24 07:08:03
问题 I'm trying to query AWS EC2 AMIs from Ansible but keep running into an error when looping through the results: - hosts: localhost tasks: - name: Get AMI ec2_ami_facts: owner: amazon filters: architecture: x86_64 root-device-type: ebs register: amis - name: return filtered data debug: msg: "{{ item }}" loop: " {{ amis \ | json_query( 'Images[?Description!=`null`] \ | [?starts_with(Description,`Amazon Linux`)]' ) \ }} " The idea is to return the image documents, and later just the image IDs

Ansible callback plugin: how to get a task name with variables in it expanded?

我是研究僧i 提交于 2019-12-24 05:25:05
问题 I have a play below that contains a task with a name that has a variable in it. hosts: localhost connection: local vars: a_variable: test tasks: - name: this is a task to echo {{ a_variable }} shell: echo {{ a_variable }} When this is run on the command line, the stdout shows the task name with variable resolved/expanded to its value which is this is a task to echo test However, when I try to access the task name in the callback plugin using the properties task.name or result._task.name, the

Difference between shell and command in ansible

白昼怎懂夜的黑 提交于 2019-12-24 03:37:08
问题 I am new to ansible world can anyone help me in understanding the difference between shell and command in ansible. When to use shell and when to use command. I know one use case command module is more safe, as it is not affected by the user’s environment. 回答1: The Ansible Shell Module allows you to run arbitrary commands on a remote host, just like you were logged into the shell. The Shell and Command modules are very similar, the major difference being that the shell module does not escape

Vagrant shell and ansible provisioning fail with bitbucket

左心房为你撑大大i 提交于 2019-12-24 03:24:06
问题 I can't force vagrant provisioning to clone private git repos from bitbucket. I have vagrant 1.6.3. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.ssh.private_key_path = "~/.vagrant.d/insecure_private_key" config.ssh.forward_agent = true config.vm.define "abox" do |abox| abox.vm.box = "ubuntu/trusty32" abox.vm.hostname = "abox" abox.ssh.forward_agent = true abox.vm.network "private_network", ip: "192.168.50.4" abox.vm.network "forwarded_port", guest: 22, host: 2233 abox.vm

Merging shared parameters with environment specific parameter in Ansible

拜拜、爱过 提交于 2019-12-24 01:58:15
问题 I run my playbooks specifying the target server environment on the command line, e.g.: ansible-playbook -e env=staging playbook.yml Now I want to be able to provide parameters, e.g. dictionary of users to create on the server in such a way that there are users common to all environments, and also users that are specific to that one environment for which I run the playbook. The directory structure could look like this: ├── group_vars │ ├── all │ │ ├── users.yml │ │ │ ├── development │ │ ├──

ansible output printing unwanted things. how to format and display only specific data's

谁说我不能喝 提交于 2019-12-24 01:41:31
问题 I am using ansible 2.4 in centos, trying to run the below script in remote servers and getting the output. Here the problem is yum info output is showing with json format also. But i need to display only the output. How to remove the json format. --- - hosts: GeneralServer tasks: - name: Checking the service status shell: systemctl status {{ item }} with_items: - httpd - crond - postfix - sshd register: service - debug: var=service - name: Checking the package info shell : yum info {{ item }}

Ansible AWS: Unable to connect to EC2 instance

倖福魔咒の 提交于 2019-12-24 01:22:54
问题 What I want to achieve I want to create an EC2 instance with LAMP stack installed using one Ansible playbook. Problem The instance creation works fine, and I can modify it in the EC2 Console, but the problem appears when trying to access the instance for example install apache or create keys. This is the error: fatal: [35.154.26.86]: UNREACHABLE! => { "changed": false, "msg": "[Errno None] Unable to connect to port 22 on or 35.154.26.86", "unreachable": true } Error Screenshot Code This is my

Search Dictionary Values in Ansible

白昼怎懂夜的黑 提交于 2019-12-24 01:03:53
问题 Having a dictionary like this: ossec_datacenter: atlanta: hostname: 'server1.fakedomain.net' ip: '192.168.12.170' port: '1515' miami: hostname: 'server2.fakedomain.net' ip: '192.168.20.31' port: '1514' dallas: hostname: 'server2.fakedomain.net' ip: '192.168.20.20' port: '1515' How would I search for all values in this dictionary in my when clause? I can access variables using ossec_datacenter[ossec_dc]['hostname'] But I want so search all values to make sure no matches are present. In other

How to loop through inventory and assign value in Ansible

六眼飞鱼酱① 提交于 2019-12-24 00:55:03
问题 I have a task in my Ansible playbook that I'm wanting iterate over each host in the group that I have and for each host I would like to assign a name from the hostname list that I've created in the vars folder. I'm familiar with looping through inventory already by writing loop: "{{ groups['mygroup'] }}" and I have a list of hostnames I would like to assign each IP in 'mygroup' within the host file. # In tasks file - roles/company/tasks/main.yml - name: change hostname win_hostname: name: "{{