Add roles and variables
This commit is contained in:
@@ -1,31 +1,49 @@
|
||||
---
|
||||
- hosts: all
|
||||
- hosts: swarm_master
|
||||
become: true
|
||||
|
||||
|
||||
|
||||
vars_files:
|
||||
- group_vars/all.yml
|
||||
vars:
|
||||
swap_file_state: present
|
||||
swap_file_existing_size_mb: 0
|
||||
|
||||
roles:
|
||||
- role: geerlingguy.swap
|
||||
- role: geerlingguy.docker
|
||||
- role: common
|
||||
|
||||
tasks:
|
||||
# write hello world to a file in the home directory
|
||||
- name: write hello
|
||||
copy:
|
||||
content: "hello ansible from ansible-manager!"
|
||||
dest: /home/vagrant/hello2.txt
|
||||
mode: 0644
|
||||
become: true
|
||||
- name: Check memory and swap usage
|
||||
command: free -m
|
||||
register: memory_info
|
||||
changed_when: false
|
||||
|
||||
- name: Echo hello
|
||||
shell: echo 'hello ansible!'
|
||||
args:
|
||||
chdir: $HOME
|
||||
# Echo the contents of the hello.txt file
|
||||
- name: Echo hello
|
||||
shell: cat /home/vagrant/hello.txt
|
||||
args:
|
||||
chdir: $HOME
|
||||
# Echo the contents of the hello2.txt file
|
||||
- name: Echo hello2
|
||||
shell: cat /home/vagrant/hello2.txt
|
||||
args:
|
||||
chdir: $HOME
|
||||
- name: Ensure Python pip is installed
|
||||
package:
|
||||
name: python3-pip
|
||||
state: present
|
||||
|
||||
- name: Ensure Docker SDK for Python is installed
|
||||
pip:
|
||||
name: docker>=5.0.0
|
||||
executable: pip3
|
||||
|
||||
- name: Init a new swarm with default parameters
|
||||
community.docker.docker_swarm:
|
||||
state: present
|
||||
|
||||
- name: Debug all variables
|
||||
debug:
|
||||
msg: "swap_file_size_mb: {{ swap_file_size_mb }}, swap_file_state: {{ swap_file_state }}"
|
||||
- name: Debug Docker variables
|
||||
debug:
|
||||
msg: "docker_edition: {{ docker_edition }}, docker_packages: {{ docker_packages }}"
|
||||
# - name: Debug all host variables
|
||||
# debug:
|
||||
# var: hostvars[inventory_hostname]
|
||||
|
||||
# - name: Initialize the cluster
|
||||
# shell: docker swarm init --advertise-addr 192.168.56.10 >> cluster_initialized.txt
|
||||
|
||||
Reference in New Issue
Block a user