- name: Your playbook name
hosts: "{{ variable_host | default('localhost') }}"
become: yes
ansible-playbook playbooks/your-playbook-name.yml \
--extra-vars "variable_host=PUT-YOUR-HOST-HERE"
ansible all -m ping -u root
ansible all -m shell -a "ping -c 3 localhost" -u root
Make sure python will load all modules installed in your virtualenv.
ansible-playbook -v \
playbooks/my-playbook.yaml \
--extra-vars="ansible_python_interpreter=$(which python)"
ansible all -m ping -u root --private-key=~/.ssh/id_rsa
ansible all -m apt -a "pkg=nginx state=latest update_cache=true" -u root
Make sure your string variable is in group_vars/all.yml.
aws_access_key_id: !vault | $ANSIBLE_VAULT;1.1;AES256 39393635326661316162323939656138666562303765666138333737366139306535303432653537 3036323230616163343135393736343462346464646438320a373234383634646130666333316132 65623561393832666131656365646437643139626532623962646439376364333066323934663661 3031326632385365630a643162643562633231653132393139333737353837633931663764373239 64666537386530366564643336346630666530373664633630323730643261613563
ansible YOUR-HOST-HERE -m debug -a 'var=aws_access_key_id'