Unable to install kubelet from ansible - ansible

I'm trying to install kubelet with Ansible, but I'm struggling to do it.
This is my playbook:
---
- hosts: all
become: yes
tasks:
- name: install docker
yum:
name: docker
state: present
update_cache: true
- name: add repo
yum_repository:
name: kuberepo
description: kubernetes-repo
baseurl: "https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64"
enabled: yes
gpgcheck: yes
repo_gpgcheck: yes
gpgkey:
- "https://packages.cloud.google.com/yum/doc/yum-key.gpg"
- "https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg"
- name: setenforce
shell: setenforce 0
- name: install kubelet
yum:
name: kubelet
state: present
update_cache: true
This is the error when i run the playbook (ansible-playbook -i hosts kube-dependencies.yml)
The "ok" from [master] node is because I manually executed "sudo yum install kubelet" on that machine, and it worked.
Conclusions:
So basically, manually executing the yum install command it works, but I can't make it work with ansible.
Any clues? Thanks in advance.

I had the same issue, I fix it adding version of kubelet
apt:
name: kubelet=1.20.0-00
state: present
update_cache: true
That worked for me
same issue with kubeletadm
- name: install kubeadm
apt:
name: kubeadm=1.14.0-00
state: present
Error
solution
- name: install kubeadm
apt:
name: kubeadm=1.20.0-00
state: present
Fix the problem
I hope I've helped

The best solution is to upgrade the version to install.
in every new version k8s changed many configs so some components become npt compatible (kubelet vs kubernetes-cni (= 0.7.5) are not compatible.
version up, if not works then find another solution.
hope that this clarification help.

Related

Install ngnix on ubuntu 20.04 using ansible playbook?

Hi i am new to ansible i have to deploy nodejs12.8.4, SSL and ngnix latest to Ubuntu 20.04 server can someone guide me how to do it thank you.
this is my yml file:
hosts: all
become: true
tasks:
- name: install nodejs prerequisites
apt:
name:
- apt-transport-https
- gcc
- g++
- make
state: present
- name: add nodejs apt key
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
state: present
- name: add nodejs repository
apt_repository:
repo: deb https://deb.nodesource.com/node_12.x {{ ansible_lsb.codename }} main
state: present
update_cache: yes
- name: install nodejs
apt:
name: nodejs
state: present
it install nodejs 12 now i want to install nginx in same file how i add new task.
Try Ansible NGINX Role. See details at Github.
Q: "I want to install Nginx in the same file how I add a new task?"
A: Include the role
- include_role:
name: nginx
Download the role. See Roles and Using Roles in particular.

Ansible - How to run multiple tasks in a playbook

I'm new to ansible, and am attempting to run multiple tasks to install docker on a particular host group in an ansible playbook.
I have the following playbook...
---
- hosts: all
tasks:
- name: Update and upgrade apt packages
become: yes
apt:
upgrade: yes
update_cache: yes
cache_valid_time: 86400 #One day
- hosts: loadbalancer
become: yes
tasks:
- name: Install docker packages
apt:
name:
- 'apt-transport-https'
- 'ca-certificates'
- 'curl'
- 'software-properties-common'
state: present
- name: Add Docker official GPG key
apt-key:
url: https://download.docker.com/linux/ubuntu/gpg
This is the error I get when attempting to run the playbook...
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to be in '/home/vagrant/ansible/playbooks/hostname.yml': line 23, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Add Docker official GPG key
^ here
What am I doing wrong here?
Thanks,
It is not apt-key, it is apt_key. Please update and try again

How to fix the ansible playbook error "Unsupported parameters for (systemd) module: enable Supported parameters?

I am trying to install Apache 2, PHP on Ubuntu machine using the ansible-playbook.
I am getting the following error
Error after executing playbook
fatal: [18.220.215.181]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (systemd) module: enable Supported parameters include: daemon_reexec, daemon_reload, enabled, force, masked, name, no_block, scope, state, user"}The ansible playbook is as follows---
- hosts: all
become: yes
tasks:
- name: Chenking ping
ping:
- name: Update packages
apt:
name: apache2
update_cache: yes
state: present
- name: restart apache2 server
service:
name: apache2
enable: yes
state: restarted
- name: install php module
apt:
name: "{{ item }}"
state: present
with_items:
- php
- libapache2-mod-php5
- php-mcrypt
- php-mysql
- name: restart apache2 afetr restart
service:
name: apache2
enable: yes
state: restarted
`
The right parameter is enabled (not enable) in your service tasks.
- name: restart apache2 afetr restart
service:
name: apache2
enabled: yes
state: restarted
Change "enabled" task containing service module.
- hosts: all
become: yes
tasks:
- name: Chenking ping
ping:
- name: Update packages
apt:
name: apache2
update_cache: yes
state: present
- name: restart apache2 server
service:
name: apache2
enabled: yes
state: restarted
- name: install php module
apt:
name: "{{ item }}"
state: present
with_items:
- php
- libapache2-mod-php5
- php-mcrypt
- php-mysql
I think last task is not required.

Java installation issue using ansible playbook

I am trying to install the java8 using ansible playbook. Below is the yml file of my playbook:
---
- hosts: test2
become: true
tasks:
- name: install the java pre-requisties
apt:
name: software-properties-common
state: latest
- name: add oracle java repository
apt_repository:
repo: 'ppa:webupd8team/java'
- name: update repository
apt:
update_cache: yes
- name: Accept Java 8 License
debconf:
name: 'oracle-java8-installer'
question: 'shared/accepted-oracle-license-v1-1'
value: true
vtype: 'select'
- name: install java 8
apt:
name: oracle-java8-installer
force: yes
But i am getting the below error:
fatal: [host2]: FAILED! => {"changed": false, "msg": "No package matching 'oracle-java8-installer' is available"}
Can you please help me to fix the issue?
Any assistance will be appreciated.
Thanks in advance.
Possible Network issue with server reaching Repository, Please check locally using apt commands if package can be download.
I tried changing deb_oracle_package: 'oracle-java8-installer' to deb_oracle_package: 'openjdk-8-jre-headless' in my mains.yml for ansible.

YAML syntax error (Ansible playboook)

I am trying to write a playbook that installs Apache, but I get the below error:
The offending line appears to be:
tasks:
- name: command to install apache
^ here
Here is my YAML code:
---
- hosts: all
tasks:
- name: command to install apache
sudo: yes
yum: name=httpd state=latest
service: name=httpd state=running
What could be wrong here?
You cannot add two actions (modules) to a single task in Ansible.
You need to split yum and service into two tasks.
Also sudo declaration was deprecated long time ago and now become should be used:
---
- hosts: all
tasks:
- name: Ensure apache is installed
become: yes
yum: name=httpd state=latest
- name: Ensure httpd service is running
become: yes
service: name=httpd state=running

Resources