ansible-playbook

ERROR! conflicting action statements (expect, command) in Ansible

吃可爱长大的小学妹 提交于 2019-12-12 13:33:39
问题 I'm trying to install java on several hosts with Ansible. I looked for some examples of expect module to provide answers to the prompts. I think this syntax is quite fine: - hosts: datanode sudo: yes sudo_user: root tasks: - expect: name: install java jdk 7 command: apt-get install openjdk-7-jdk responses: Question: 'Do you want to continue? [Y/n]': 'Y' But when I try to execute ansible-playbook file.yml I receive the error: ERROR! conflicting action statements (expect, command) The error

All Ansible playbook attributes

梦想的初衷 提交于 2019-12-12 13:13:26
问题 I've just started using Ansible, and after reading the tutorial (which Ansible Team named "docs" ) I would like to see the full list of all attributes which can be used in playbooks. Is someone able to provide such a list? The only one I was able to Google was this old example but it lack the things like gather_facts . Maybe someone experienced could paste here a 'skeleton' with the correct structure containing all the atributes. Thanks in advance. 回答1: You can always look into the code: # ==

Ansible text file busy error

若如初见. 提交于 2019-12-12 11:13:32
问题 I have a Vagrant / Ansible set up on my Windows host. Ansible is set up to run on the Ubuntu guest, as Vagrant up executes a shell script which copies the provisioning yml files onto the guest and installs Ansible also on the guest. The script runs the Ansible set up on the guest with the following command: # Ansible installations sudo apt-get install -y ansible # Copy all Ansible scripts to the ubuntu guest sudo cp -rf -v /vagrant/provisioning /home/vagrant/ # cp /vagrant/hosts /home/vagrant

Ansible - only run a series of tasks if a precondition is met

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 10:51:36
问题 I have a package I need to install from a remote URL as in: - get-url: url=http://foo.com/foo.deb dest=/tmp - command: dpkg --skip-same-version -i /tmp/foo.deb - apt: update_cache=yes - apt: pkg=foo state=present I'd only like to run the first 3 if pkg=foo isn't already present. What's the best way to achieve this? 回答1: You have to register a variable with the result, and then use when statement. tasks: - shell: /usr/bin/foo register: result ignore_errors: True - debug: msg="it failed" when:

How to create a file locally with ansible templates on the development machine

六眼飞鱼酱① 提交于 2019-12-12 09:29:41
问题 I'm starting out with ansible and I'm looking for a way to create a boilerplate project on the server and on the local environment with ansible playbooks. I want to use ansible templates locally to create some generic files. But how would i take ansible to execute something locally? I read something with local_action but i guess i did not get this right. This is for the webbserver...but how do i take this and create some files locally? - hosts: webservers remote_user: someuser - name: create

Ansible playbook run for the servers in the list

谁说我不能喝 提交于 2019-12-12 05:48:35
问题 quick question for Ansible Guru's. I want to run an ansible playbook for a specific set of boxes that I copied to a list.txt disregarding the inventory and the target block in ansible playbook: --- - name: Ansible Runbook v.1.0 hosts: test1 gather_facts: yes # serial: "10%" When I am running the following command I am getting no hosts matched: ansible-playbook playbook.yaml --tags "simplejson" -vvv -i /x/home/list.txt PLAY [Ansible Runbook v.1.0] **********************************************

Forced to create file beforehand ansible conditional include

亡梦爱人 提交于 2019-12-12 05:16:17
问题 # "Run application specific configuration scripts" - include: "app_cfg/{{ app_name }}.yml" when: "{{ app_conf[app_name].app_cfg }}" ignore_errors: no tags: - conf I thought that I will be able conditionally include application specific playbooks simply by setting one variable to the true/false value like so: app_conf: my_app_1: app_cfg: no my_app_2: app_cfg: yes Unfortunately Ansible is forcing me to create file beforehand: ERROR: file could not read: <...>/tasks/app_cfg/app_config.yml Is

Dynamic groups based on ip range in Ansible groups

蹲街弑〆低调 提交于 2019-12-12 05:06:40
问题 How to create variable group based on ip address-range in ansible inventory groups ? I have two groups of servers in different location. I want to create the groups every time the playbook so that the playbook is run on a updated list of servers. I already groups based on distribution, prod, dev, test, qa ,dr in my host inventory. Thanks in Advance 回答1: You can scan all hosts at the beginning and group them how you want, e.g. by network: - hosts: all tasks: - group_by: key=network_{{ ansible

Installing VMware Tools on virtual machines using Ansible

自闭症网瘾萝莉.ら 提交于 2019-12-12 04:26:07
问题 I am trying to install VMware Tools on various OS on my guest machines. This is the code I have now. --- - hosts: all tasks: - name: debian | installing open-vm-tools apt: name=open-vm-tools state=present when: ansible_os_family == "Debian" - name: install vmware tools via Chocolatey win_chocolatey: name=vmware-tools state=present when: ansible_distribution == "Windows" This is what my hosts.ini file looks like: [my-host] myhost.com ansible_ssh_pass=mypw ansible_ssh_user=root This is the

Unable to Create a CloudWatch Healthcheck via Ansible

爱⌒轻易说出口 提交于 2019-12-12 03:47:03
问题 I have a inventory file which has a RDS endpoint as : [ems_db] syd01-devops.ce4l9ofvbl4z.ap-southeast-2.rds.amazonaws.com I wrote the following play book to create a Cloudwatch ALARM : --- - name: Get instance ec2 facts debug: var=groups.ems_db[0].split('.')[0] register: ems_db_name - name: Display debug: var=ems_db_name - name: Create CPU utilization metric alarm ec2_metric_alarm: state: present region: "{{aws_region}}" name: "{{ems_db_name}}-cpu-util" metric: "CPUUtilization" namespace: