Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ANSIBLE
- =======
- (on master)
- $ sudo amazon-linux-extras install ansible2 -y
- $ ansible --version
- ansible 2.9.23
- config file = /etc/ansible/ansible.cfg
- configured module search path = [u'/home/ec2-user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
- ansible python module location = /usr/lib/python2.7/site-packages/ansible
- executable location = /usr/bin/ansible
- python version = 2.7.18 (default, May 25 2022, 14:30:51) [GCC 7.3.1 20180712 (Red Hat 7.3.1-15)]
- $ cat inventory
- [amazon]
- 172.31.14.237 ansible_user="ec2-user" ansible_port=22 ansible_ssh_private_key_file="aws.pem"
- $ ansible -i inventory amazon -m ping
- The authenticity of host '172.31.14.237 (172.31.14.237)' can't be established.
- ECDSA key fingerprint is SHA256:VE2/2D9i0H3vi84ly3Vp1qW7C5VEZbQ3d38Z41e9IcQ.
- ECDSA key fingerprint is MD5:9c:37:9f:28:a4:08:c7:99:ea:ff:66:fe:72:c2:15:21.
- Are you sure you want to continue connecting (yes/no)? yes
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | SUCCESS => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": false,
- "ping": "pong"
- }
- $ ansible -i inventory amazon -m yum -a "name=httpd state=present"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | FAILED! => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": false,
- "changes": {
- "installed": [
- "httpd"
- ]
- },
- "msg": "You need to be root to perform this command.\n",
- "rc": 1,
- "results": [
- "Loaded plugins: extras_suggestions, langpacks, priorities, update-motd\n"
- ]
- }
- $ ansible -i inventory amazon -b -m yum -a "name=httpd state=present"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- $ ansible -i inventory amazon -b -m yum -a "name=httpd state=present"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | SUCCESS => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": false,
- $ ansible -i inventory amazon -b -m yum -a "name=httpd,php state=present"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "changes": {
- "installed": [
- "PHP"
- $ ansible -i inventory amazon -b -m yum -a "name=httpd,php,mariadb-server state=present"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "changes": {
- "installed": [
- "mariadb-server"
- $ ansible -i inventory -b amazon -m service -a "name=httpd state=started"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "name": "httpd",
- "state": "started",
- $ ansible -i inventory -b amazon -m service -a "name=mariadb state=started"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "name": "mariadb",
- "state": "started",
- $ ansible -i inventory -b amazon -m service -a "name=httpd state=started"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | SUCCESS => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": false,
- "name": "httpd",
- "state": "started",
- $ ansible -i inventory -b amazon -m service -a "name=mariadb state=stopped"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "name": "mariadb",
- "state": "stopped",
- $ wget https://www.tooplate.com/zip-templates/2128_tween_agency.zip ; unzip 2128_tween_agency.zip ; mv 2128_tween_agency website ; rm -rf *.zip
- $ ansible -i inventory -b amazon -m copy -a "src=./website/ dest=/var/www/html/"
- 172.31.14.237 | CHANGED => {
- "changed": true,
- "dest": "/var/www/html/",
- "src": "/home/ec2-user/./website/"
- }
- $ ansible -i inventory -b amazon -m copy -a "src=./website/ dest=/var/www/html/"
- 172.31.14.237 | SUCCESS => {
- "changed": false,
- "dest": "/var/www/html/",
- "src": "/home/ec2-user/./website/"
- }
- $ ansible -i inventory -b amazon -m copy -a "src=./website/ dest=/var/www/html/"
- 172.31.14.237 | CHANGED => {
- "changed": true,
- "dest": "/var/www/html/",
- "src": "/home/ec2-user/./website/"
- }
- $ cat simple-site-hosting-playbook.yml
- ---
- - name: "site hosting"
- hosts: amazon
- become: true
- tasks:
- - name: "installing httpd"
- yum:
- name: httpd
- state: present
- - name: "starting httpd service"
- service:
- name: httpd
- state: started
- enabled: true
- - name: "copying site contents"
- copy:
- src: "./website/"
- dest: "/var/www/html/"
- owner: apache
- group: apache
- $ ansible-playbook -i inventory simple-site-hosting-playbook.yml --syntax-check
- playbook: simple-site-hosting-playbook.yml
- $ ansible-playbook -i inventory simple-site-hosting-playbook.yml
- PLAY [site hosting] ****************************************************************************************************************************
- TASK [Gathering Facts] *************************************************************************************************************************
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- ok: [172.31.14.237]
- TASK [installing httpd] ************************************************************************************************************************
- ok: [172.31.14.237]
- TASK [starting httpd service] ******************************************************************************************************************
- changed: [172.31.14.237]
- TASK [copying site contents] *******************************************************************************************************************
- changed: [172.31.14.237]
- PLAY RECAP *************************************************************************************************************************************
- 172.31.14.237 : ok=4 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- $ ansible -i inventory -b amazon -m yum -a "name=* state=latest"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- $ cat sreehari.txt
- content1
- $ ansible -i inventory amazon -m copy -a "src=sreehari.txt dest=/tmp/"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "checksum": "b29930dda02406077d96a7b7a08ce282b3de6961",
- "dest": "/tmp/sreehari.txt",
- $ ansible -i inventory amazon -m file -a "path=/tmp/sreehari.txt state=absent"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "path": "/tmp/sreehari.txt",
- "state": "absent"
- }
- $ ansible -i inventory amazon -m copy -a "src=sreehari.txt dest=/tmp/"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "checksum": "b29930dda02406077d96a7b7a08ce282b3de6961",
- "dest": "/tmp/sreehari.txt",
- $ ansible -i inventory amazon -m copy -a "src=sreehari.txt dest=/tmp/linux.txt"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "checksum": "b29930dda02406077d96a7b7a08ce282b3de6961",
- "dest": "/tmp/linux.txt",
- $ ansible -i inventory amazon -m file -a "src=/tmp/linux.txt dest=/tmp/sreehari.txt state=link"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "dest": "/tmp/sreehari.txt",
- "gid": 1000,
- "group": "ec2-user",
- "mode": "0777",
- "owner": "ec2-user",
- "size": 14,
- "src": "/tmp/linux.txt",
- "state": "link",
- "uid": 1000
- $ ansible -i inventory -b amazon -m user -a "name=user state=present"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- $ ansible -i inventory -b amazon -m user -a "name=user state=absent"
- [WARNING]: Platform linux on host 172.31.14.237 is using the discovered Python interpreter at /usr/bin/python, but future installation of
- another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
- information.
- 172.31.14.237 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/bin/python"
- },
- "changed": true,
- "force": false,
- "name": "user",
- "remove": false,
- "state": "absent"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement