Skip to content

Instantly share code, notes, and snippets.

@gfranchini
Last active February 18, 2019 01:09
Show Gist options
  • Save gfranchini/fa7d8bd2eada617709b114641f15ceec to your computer and use it in GitHub Desktop.
Save gfranchini/fa7d8bd2eada617709b114641f15ceec to your computer and use it in GitHub Desktop.
Install multiple packages w ansible
--- │Kernel has been successfully updated to kernel-3.10.0-957.5.1.el7.x86_64!
- hosts: webservers │[ansible@digistro3c ~]$ cd
become: true │[ansible@digistro3c ~]$ ls
tasks: │inventory.ini playbooks
- name: Install packages │[ansible@digistro3c ~]$ cd playbooks/
yum: │[ansible@digistro3c playbooks]$ ls
name: "{{ packages }}" │hostname.yml httpd.yml nginx.yml
state: present │[ansible@digistro3c playbooks]$ w
update_cache: yes │ 00:27:38 up 30 min, 2 users, load average: 0.00, 0.01, 0.05
vars: │USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
packages: │cloud_us pts/0 104-184-249-209. 23:58 10.00s 1.54s 2.67s sshd: cloud_user [priv]
- httpd │ansible pts/1 104-184-249-209. 00:27 2.00s 0.08s 0.00s w
- vim │[ansible@digistro3c playbooks]$ which httpd
- nano │/usr/bin/which: no httpd in (/usr/local/rvm/gems/ruby-2.4.1/bin:/usr/local/rvm/gems/ruby-2.4.1@glo
- name: Start Httpd │bal/bin:/usr/local/rvm/rubies/ruby-2.4.1/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/us
service: │r/local/rvm/bin:/home/ansible/.local/bin:/home/ansible/bin)
name: httpd │[ansible@digistro3c playbooks]$ systemctl status httpd
state: started │Unit httpd.service could not be found.
enabled: yes │[ansible@digistro3c playbooks]$
- name: Create index.html │
file: │
path: /var/www/html/index.html │
state: touch │
- name: Add a line to index.html │
lineinfile: │
path: /var/www/html/index.html │
line: "Hello World!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment